I am working with Visual Studio 2013, .NET4.5.
Originally I was WCF service consumer but due to lack of resources in team that deals with subsystem I took over development of both sides of WCF service. So I got code of the WCF service that I need ran it on local. Plugged it in by deleting old Service Reference and then adding New Service Reference
using Visual Studio UI. It generated me client and configuration.
It builds and runs fine however when I call the service I get error:
C# code: (which is pretty much irrelevant here but someone will ask for it anyway)
public class LeafManager
{
public LeafManager(ICorePricingService pricing, IWebQuoteService quote, IWebPaymentService payment)
{
this.Pricing = pricing;
this.Quote = quote;
this.Payment = payment;
}
public IWebPaymentService Payment { get; set; }
public IWebQuoteService Quote { get; set; }
public ICorePricingService Pricing { get; private set; }
public List<Core.WillProductValuation> GetWillProducts(bool? isMirror, List<Core.QuestionAnswer> questions,
List<string> discountCodes)
{
var result = this.Pricing.GetWillsPrices(new WillPricingParameters{Questions = questions.ToLeafPayment(), DiscountCodes = discountCodes.ToArray(), IsCouple = isMirror});
return result.ToLocal();
}
...
}
Web.config (that was generated by VS2013)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="ConveyancingEndpoint">
<security mode="Transport" />
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://localhost:44301/CorePricingService.svc"
binding="wsHttpBinding" bindingConfiguration="ConveyancingEndpoint"
contract="ServiceReference2.ICorePricingService" name="ConveyancingEndpoint">
<identity>
<userPrincipalName value="matas.vaitkevicius@group......co.uk" />
</identity>
</endpoint>
</client>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
Exception:
{"The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate oYIETTCCBEmgAwoBA...'."}
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest request, HttpWebResponse response, WebException responseException, HttpChannelFactory`1 factory)
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at XXX.Legal.Webservices.ServiceReference2.ICorePricingService.GetWillsPrices(WillPricingParameters willPricingParameters)
at XXX.Legal.Webservices.ServiceReference2.CorePricingServiceClient.GetWillsPrices(WillPricingParameters willPricingParameters) in c:\XXX.Legal\XXX.Legal\XXX.Legal.Webservices\Service References\ServiceReference2\Reference.cs:line 673
at XXX.Legal.Webservices.LeafManager.GetWillProducts(Nullable`1 isMirror, List`1 questions, List`1 discountCodes) in c:\XXX.Legal\XXX.Legal\XXX.Legal.Webservices\LeafManager.cs:line 26
at XXX.Legal.Website.Areas.Wills.Controllers.JourneyController.Quote() in c:\XXX.Legal\XXX.Legal\XXX.Legal.Website\Areas\Wills\Controllers\JourneyController.cs:line 90
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.InvokeSynchronousActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41()
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49()
Inner Exception:
{"The remote server returned an error: (401) Unauthorized."}
stack trace:
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
Even more Inner Exception:
{"The target principal name is incorrect"}
stack trace:
at System.Net.NTAuthentication.GetOutgoingBlob(Byte[] incomingBlob, Boolean throwOnError, SecurityStatus& statusCode)
at System.Net.NTAuthentication.GetOutgoingBlob(String incomingBlob)
at System.Net.NegotiateClient.DoAuthenticate(String challenge, WebRequest webRequest, ICredentials credentials, Boolean preAuthenticate)
at System.Net.NegotiateClient.Authenticate(String challenge, WebRequest webRequest, ICredentials credentials)
at System.Net.AuthenticationManager.Authenticate(String challenge, WebRequest request, ICredentials credentials)
at System.Net.AuthenticationState.AttemptAuthenticate(HttpWebRequest httpWebRequest, ICredentials authInfo)
at System.Net.HttpWebRequest.CheckResubmitForAuth()
at System.Net.HttpWebRequest.CheckResubmit(Exception& e, Boolean& disableUpload)
If we look at innermost exception it states that The target principal name is incorrect
which would imply that (WCF) generated incorrect UPN. I must be missing something obvious here.