I Hosted WCf Service in IIS and made that as independent virtual directory. When I host this service I Can see the Methods of WCF from WCF test client but can't access the data..
Could you quickly suggest where I'm going wrong
below is my code:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MobServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="WebBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
<services>
<service name="ClubConnect.MobService" behaviorConfiguration="MobServiceBehavior">
<endpoint address="" binding="wsHttpBinding" contract="ClubConnect.IMobService"/>
<endpoint address="ws" name="webHttpBinding" binding="webHttpBinding" contract="ClubConnect.IMobService" behaviorConfiguration="WebBehavior" >
<identity>
<dns value="http://domain/mobile_app/mobservice.svc" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
Error:
The content type text/html; charset=UTF-8 of the response message does
not match the content type of the binding (application/soap+xml;
charset=utf-8). If using a custom encoder, be sure that the
IsContentTypeSupported method is implemented properly. The first 1024
bytes of the response were: ' '. Server stack trace: at
System.ServiceModel.Security.IssuanceTokenProviderBase1.DoNegotiation(TimeSpan
timeout) at
System.ServiceModel.Security.SspiNegotiationTokenProvider.OnOpen(TimeSpan
timeout) at
System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan
timeout) at
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout) at
System.ServiceModel.Security.CommunicationObjectSecurityTokenProvider.Open(TimeSpan
timeout) at
System.ServiceModel.Security.SymmetricSecurityProtocol.OnOpen(TimeSpan
timeout) at
System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan
timeout) at
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout) at
System.ServiceModel.Channels.SecurityChannelFactory1.ClientSecurityChannel1.OnOpen(TimeSpan
timeout) at
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout) at
System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.DoOperation(SecuritySessionOperation
operation, EndpointAddress target, Uri via, SecurityToken
currentToken, TimeSpan timeout) at
System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.GetTokenCore(TimeSpan
timeout) at
System.IdentityModel.Selectors.SecurityTokenProvider.GetToken(TimeSpan
timeout) at
System.ServiceModel.Security.SecuritySessionClientSettings1.ClientSecuritySessionChannel.OnOpen(TimeSpan
timeout) at
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout) at
System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout) at
System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel
channel, TimeSpan timeout) at
System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan
timeout, CallOnceManager cascade) at
System.ServiceModel.Channels.ServiceChannel.Call(String action,
Boolean oneway, ProxyOperationRuntime operation, Object[] ins,
Object[] outs, TimeSpan timeout) 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 IMobService.GetCategoryList() at
MobServiceClient.GetCategoryList()
Related
I've tried to execute a method of a web service on my console application (c# .Net 4.5.2), but I've received the following error: "(415) Cannot process the message because the content type 'application/xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'.."
app.config
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="AnotherBindingWS"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647" />
</webHttpBinding>
<basicHttpBinding>
<binding name="BasicHttpBinding_IIntegracion"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"/>
</basicHttpBinding>
</bindings>
<client>
<endpoint
name="BasicHttpBinding_IIntegracion"
address="http://servicios.cruzdelsur.com/Interfaces_Test/Integracion.svc"
binding="webHttpBinding"
bindingConfiguration="AnotherBindingWS"
contract="WSIntegracionCDS.IIntegracion"
behaviorConfiguration="webhttp"/>
</client>
<services>
<service name="WSIntegracionCDS.IIntegracion">
<endpoint
name="AnotherBindingServiceWS"
address="http://servicios.cruzdelsur.com/Interfaces_Test/Integracion.svc"
binding="webHttpBinding"
bindingConfiguration="AnotherBindingWS"
contract="WSIntegracionCDS.IIntegracion"
behaviorConfiguration="webhttp"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webhttp">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
Program.cs
IntegracionClient clientWS = new IntegracionClient();
CrearDespachos_Input inputDespachosWS = new CrearDespachos_Input();
List<Despacho> newDespachos = new List<Despacho>();
foreach (var cbte in comprobantesCDS)
{
Despacho itemDespacho = GetNewDespacho(cbte);
newDespachos.Add(itemDespacho);
}
inputDespachosWS.Despachos = newDespachos.ToArray();
//On the following line I receive the exception
CrearDespachos_Output output = clientWS.CrearDespachos(inputDespachosWS);
I attached the exception on execution CrearDespachos method Exception on runtime
ex.StackTrace
Server stack trace:
en System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
en System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
en System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
en System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
en System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
en System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
en System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
en System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
en System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
en ESAIntegracionesService.WSIntegracionCDS.IIntegracion.CrearDespachos(CrearDespachos_Input Input)
en ESAIntegracionesService.WSIntegracionCDS.IntegracionClient.CrearDespachos(CrearDespachos_Input Input) en C:\dev\esa-web\ESAIntegracionesService\Service References\WSIntegracionCDS\Reference.cs:línea 2691
en ESAIntegracionesService.Program.ActualizarComprobantes(String token) en C:\dev\esa-web\ESAIntegracionesService\Program.cs:línea 121
¿Could you help me?
Thanks a lot!
I am trying to call a WCF from my C# desktop app but i get an error. This is my code:
//Client Code
System.ServiceModel.EndpointAddress addressSync = new System.ServiceModel.EndpointAddress("net.tcp://an ip address/Sync2.svc");
Shared.FactorySync = new System.ServiceModel.ChannelFactory<LiteEdition.wsSyncFastest.ISync2Channel>("NetTcpBinding_ISync2", addressSync);
Shared.UpLoadSync = Shared.FactorySync.CreateChannel();
[QUESTION. If I dynamically create a client call to a WCF can I assume i do NOT need to include anything in th app.config file about the bindings?]
//error message on this line:
Shared.UpLoadSync.UploadMotionDynamic2(new byte[1]{0}, 0, 0);
//IS:
The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.9349963'
.
//My Service:
public void UploadMotionDynamic2(byte[] jpegData, int status, int framePart)
{
DAL dal = new DAL();
try
{
if (jpegData != null)
{
LiveView2.SetNewFrame(status, framePart, jpegData);
}
}
catch (Exception ex)
{
email.SendError("Sync.UploadMotionDynamic:" + ex.ToString(), "");
}
}
//In my Web.Config
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="NetTCPBehaviour">
<serviceTimeouts transactionTimeout="0.00:00:30" />
<serviceDebug includeExceptionDetailInFaults="false" />
<dataContractSerializer maxItemsInObjectGraph="65536" />
<serviceMetadata httpGetEnabled="true" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="testme" behaviorConfiguration="NetTCPBehaviour">
<endpoint address="Sync2.svc" binding="netTcpBinding" contract="ISync" name="wsMotionUploader" bindingConfiguration="NetTCPBindingEndPoint">
<!--<security mode="None"></security>-->
</endpoint>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="NetTCPBindingEndPoint" receiveTimeout="00:15:00" sendTimeout="00:15:00" transferMode="Streamed" closeTimeout="00:02:00" openTimeout="00:02:00"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
<readerQuotas maxArrayLength="32768" />
<security mode="None">
<transport clientCredentialType="None" protectionLevel="None" />
<message clientCredentialType="None" />
</security>
</binding>
</netTcpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Amended Code:
System.ServiceModel.NetTcpBinding binding = new System.ServiceModel.NetTcpBinding();
System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress("http:ip/Sync2");
System.ServiceModel.ChannelFactory<System.ServiceModel.Channels.IRequestChannel> factory =
new System.ServiceModel.ChannelFactory<System.ServiceModel.Channels.IRequestChannel>(binding, address);
var channel = factory.CreateChannel();
channel.Open();
UPDATED TO THIS:
System.ServiceModel.NetTcpBinding binding = new System.ServiceModel.NetTcpBinding();
System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress("net.tcp://ip/Sync2");
System.ServiceModel.ChannelFactory<WindowsFormsApplication2.ws.ISync2Channel> factory =
new System.ServiceModel.ChannelFactory<WindowsFormsApplication2.ws.ISync2Channel>(binding, address);
factory.Endpoint.Contract.SessionMode = System.ServiceModel.SessionMode.Allowed;
WindowsFormsApplication2.ws.ISync2Channel channel = factory.CreateChannel();
channel.Open();
But get this error 'Object reference not set to an instance of an object.'
on the .Open() method.
Also, the 'WindowsFormsApplication2.ws.ISync2Channel' is defined because I had already added a reference to the Service. If I had not what would I have
used instead?
///******************new settings:
Client code:
ws.Sync2Client wcf = new ws.Sync2Client("NetTcpBinding_ISync2");
wcf.UploadMotionDynamic2(new byte[1]{1},0,0);
Client App.Config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ISync2" />
</basicHttpBinding>
<netTcpBinding>
<binding name="NetTcpBinding_ISync2" />
</netTcpBinding>
</bindings>
<client>
<endpoint address="http://ip/Sync2.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISync2"
contract="ws.ISync2" name="BasicHttpBinding_ISync2" />
<endpoint address="net.tcp://ip/Sync2.svc" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_ISync2" contract="ws.ISync2"
name="NetTcpBinding_ISync2">
<identity>
<servicePrincipalName value="host/ip" />
</identity>
</endpoint>
</client>
</system.serviceModel>
Server Web.Config
-->
The error I get is on this line:
wcf.UploadMotionDynamic2(new byte[1]{1},0,0);
The error is:
Object reference not set to an instance of an object.
the stack is:
Server stack trace:
at System.ServiceModel.Channels.SocketConnectionInitiator.Connect(Uri uri, TimeSpan timeout)
at System.ServiceModel.Channels.BufferedConnectionInitiator.Connect(Uri uri, TimeSpan timeout)
at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(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 WindowsFormsApplication2.ws.ISync2.UploadMotionDynamic2(Byte[] jpegData, Int32 status, Int32 framePart)
at WindowsFormsApplication2.ws.Sync2Client.UploadMotionDynamic2(Byte[] jpegData, Int32 status, Int32 framePart) in m:\Visual Studio 2013\Projects\WindowsFormsApplication2\WindowsFormsApplication2\Service References\ws\Reference.cs:line 81
at WindowsFormsApplication2.Form1.button1_Click(Object sender, EventArgs e) in m:\Visual Studio 2013\Projects\WindowsFormsApplication2\WindowsFormsApplication2\Form1.cs:line 581
This all works when I use http binding though...
The port 780 is open on my server.
the Net.Tcp.Listener Adaptor is running
Enabled Protocols in IIS has net.tcp
Still no joy
It looks like your using the wrong constructor for your requirements.
When using the ChannelFactory(String, EndpointAddress) constructor, the first parameter stands for the name of your endpoint configuration (in your config file).
Using the ChannelFactory(Binding, EndpointAddress) constructor will fulfill your requirement of passing the configuration programmatically.
Use this constructor when you want to pass the binding and address information programmatically rather than using an application configuration file.
You can use the ChannelFactory class to call the wcf service, in this case you dont need to have endpoints and bindings in configuration file. Everything(endpoints, behaviors) you can create in the c# something like below code
var channelFactory = new ChannelFactory<IService>(new BasicHttpBinding(), "http://myurl:8080/ServiceFirst");
IService client = channelFactory.CreateChannel();
check out this link
http://msdn.microsoft.com/en-us/library/ms734681(v=vs.110).aspx
I'm trying to create a WCF service that uses the MembershipProvider for authentication. Because it is an internal service I'm currently not interested in applying transport level security (HTTPS) and I want to (for now) do this without a certificate. Besides, this will complicate rolling out the service and I wish to do this at a later point in time. I've built a basic configuration (even without configuring the MembershipProvider, but WCF keeps throwing me the following exception:
The service certificate is not provided. Specify a service certificate
in ServiceCredentials.
Here's my configuration:
<system.serviceModel>
<bindings>
<ws2007HttpBinding>
<binding name="Service1WS2007HttpBindingConfig">
<security mode="Message">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" />
</security>
</binding>
</ws2007HttpBinding>
</bindings>
<services>
<service name="WcfService1.Service1">
<endpoint address="http://localhost:9800/Service1.svc"
binding="ws2007HttpBinding"
bindingConfiguration="Service1WS2007HttpBindingConfig"
contract="WcfService1.IService1" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false">
<serviceActivations>
<add relativeAddress="Service1.svc" service="WcfService1.Service1" />
</serviceActivations>
</serviceHostingEnvironment>
</system.serviceModel>
Stacktrace of the exception:
[InvalidOperationException: The service certificate is not provided.
Specify a service certificate in ServiceCredentials. ]
System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateServerX509TokenProvider()
+12382737 System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateLocalSecurityTokenProvider(RecipientServiceModelSecurityTokenRequirement
recipientRequirement) +63
System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateSecurityTokenProvider(SecurityTokenRequirement
requirement) +48
System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateTlsnegoServerX509TokenProvider(RecipientServiceModelSecurityTokenRequirement
recipientRequirement) +191
System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateTlsnegoSecurityTokenAuthenticator(RecipientServiceModelSecurityTokenRequirement
recipientRequirement, Boolean requireClientCertificate,
SecurityTokenResolver& sctResolver) +683
System.ServiceModel.Security.ServiceCredentialsSecurityTokenManager.CreateSecurityTokenAuthenticator(SecurityTokenRequirement
tokenRequirement, SecurityTokenResolver& outOfBandTokenResolver)
+12383208 System.ServiceModel.Security.SessionRenewSecurityTokenManager.CreateSecurityTokenAuthenticator(SecurityTokenRequirement
tokenRequirement, SecurityTokenResolver& outOfBandTokenResolver) +81
System.ServiceModel.Security.SymmetricSecurityProtocolFactory.OnOpen(TimeSpan
timeout) +181
System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan
timeout) +21
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout) +318
System.ServiceModel.Security.SecurityListenerSettingsLifetimeManager.Open(TimeSpan
timeout) +94
System.ServiceModel.Channels.SecurityChannelListener`1.OnOpen(TimeSpan
timeout) +240
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout) +318
System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan
timeout) +72
[InvalidOperationException: The ChannelDispatcher at
'http://localhost:9800/Service1.svc' with contract(s)
'"IssueAndRenewSession"' is unable to open its IChannelListener.]
System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan
timeout) +118
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout) +318 System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan
timeout) +111
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout) +318
System.ServiceModel.Security.SecuritySessionSecurityTokenAuthenticator.OnOpen(TimeSpan
timeout) +131
System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan
timeout) +21
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout) +318
System.ServiceModel.Security.CommunicationObjectSecurityTokenAuthenticator.Open(TimeSpan
timeout) +20
System.ServiceModel.Security.SecuritySessionServerSettings.OnOpen(TimeSpan
timeout) +792
System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan
timeout) +21
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout) +318
System.ServiceModel.Security.SecurityListenerSettingsLifetimeManager.Open(TimeSpan
timeout) +148
System.ServiceModel.Channels.SecurityChannelListener`1.OnOpen(TimeSpan
timeout) +240
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout) +318
System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan
timeout) +72
[InvalidOperationException: The ChannelDispatcher at
'http://localhost:9800/Service1.svc' with contract(s) '"IService1"' is
unable to open its IChannelListener.]
System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan
timeout) +118
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout) +318 System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan
timeout) +111
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout) +318
System.ServiceModel.HostingManager.ActivateService(String
normalizedVirtualPath) +206
System.ServiceModel.HostingManager.EnsureServiceAvailable(String
normalizedVirtualPath) +651
[ServiceActivationException: The service '/Service1.svc' cannot be
activated due to an exception during compilation. The exception
message is: The ChannelDispatcher at
'http://localhost:9800/Service1.svc' with contract(s) '"IService1"' is
unable to open its IChannelListener..]
System.Runtime.AsyncResult.End(IAsyncResult result) +688590
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult
result) +190
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication
context, String routeServiceVirtualPath, Boolean flowContext, Boolean
ensureWFService) +234
System.ServiceModel.Activation.HttpModule.ProcessRequest(Object
sender, EventArgs e) +359
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+148 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
What is wrong with my configuration and how can I solve this?
You need to sign the service with a certificate. You can do this by adding the following to the configuration:
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
*<serviceCredentials>
<serviceCertificate findValue="certificatename" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
</serviceCredentials>*
</behavior>
</serviceBehaviors>
Where certificatename is the name of your certificate. To create a certificate you can look here:
Create a self signed certificate
Setting <security mode="None"> and commenting the serviceCertificate tag inside <serviceCredentials> in my Web.config solved the problem for me.
I was having this problem in localhost, so I didn't need these security settings.
i am getting the following error when i try access my webservice from the client application which is a windows based app
System.ServiceModel.Security.SecurityNegotiationException:
Secure channel cannot be opened
because security negotiation with the
remote endpoint has failed. This may
be due to absent or incorrectly
specified EndpointIdentity in the
EndpointAddress used to create the
channel. Please verify the
EndpointIdentity specified or implied
by the EndpointAddress correctly
identifies the remote endpoint. --->
System.ServiceModel.FaultException:
The request for security token has
invalid or malformed elements. at
System.ServiceModel.Security.SecurityUtils.ThrowIfNegotiationFault(Message
message, EndpointAddress target) at
System.ServiceModel.Security.IssuanceTokenProviderBase`1.ThrowIfFault(Message
message, EndpointAddress target) at
System.ServiceModel.Security.SspiNegotiationTokenProvider.GetNextOutgoingMessageBody(Message
incomingMessage,
SspiNegotiationTokenProviderState
sspiState) --- End of inner
exception stack trace ---
Server stack trace: at
System.ServiceModel.Security.IssuanceTokenProviderBase1.DoNegotiation(TimeSpan
timeout) at
System.ServiceModel.Security.SspiNegotiationTokenProvider.OnOpen(TimeSpan
timeout) at
System.ServiceModel.Security.TlsnegoTokenProvider.OnOpen(TimeSpan
timeout) at
System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan
timeout) at
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout) at
System.ServiceModel.Security.SecurityUtils.OpenCommunicationObject(ICommunicationObject
obj, TimeSpan timeout) at
System.ServiceModel.Security.SymmetricSecurityProtocol.OnOpen(TimeSpan
timeout) at
System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan
timeout) at
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout) at
System.ServiceModel.Channels.SecurityChannelFactory1.ClientSecurityChannel1.OnOpen(TimeSpan
timeout) at
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout) at
System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.DoOperation(SecuritySessionOperation
operation, EndpointAddress target, Uri
via, SecurityToken currentToken,
TimeSpan timeout) at
System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.GetTokenCore(TimeSpan
timeout) at
System.IdentityModel.Selectors.SecurityTokenProvider.GetToken(TimeSpan
timeout) at
System.ServiceModel.Security.SecuritySessionClientSettings1.ClientSecuritySessionChannel.OnOpen(TimeSpan
timeout) at
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout) at
System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan
timeout) at
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout) at
System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan
timeout, CallOnceManager cascade)
at
System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan
timeout) at
System.ServiceModel.Channels.ServiceChannel.Call(String
action, Boolean oneway,
ProxyOperationRuntime operation,
Object[] ins, Object[] outs, TimeSpan
timeout) at
System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage
methodCall, ProxyOperationRuntime
operation) at
System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage
message)
i am also using asp membership provider....
i have been trying to get this working for the last couple hours but i'm getting nowhere..... the funny thing is that the app works on the local machine but not from a remote machine
thanks
{
<services>
<service name="AutoWatch.Entity.WcfService.SecurityService" behaviorConfiguration="ServiceBehavior">
<endpoint binding="wsHttpBinding" bindingConfiguration="ServiceBinding" bindingName="ServiceBinding" contract="AutoWatch.Entity.WcfService.ISecurityService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost..." />
</baseAddresses>
</host>
</service>
<service name="servicename" behaviorConfiguration="ServiceBehavior">
<endpoint binding="wsHttpBinding" bindingConfiguration="ServiceBinding" bindingName="ServiceBinding" contract="Service" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost/.../" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="ServiceBinding"></binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<!-- Configure role based authorization to use the Role Provider -->
<serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="SqlRoleProvider" />
<serviceCredentials>
<!-- Configure user name authentication to use the Membership Provider -->
<userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="SqlMembershipProvider" />
<!-- Configure the service certificate -->
<serviceCertificate storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" findValue="......co.za" />
</serviceCredentials>
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True" />
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
}
I am having try trying to consume a service. I am trying to deploy it to a server and consume it however I get this error. I have created a web application and added a wcf service. I am getting this
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory.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.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 IBusinessV1.CheckForUpdate(String currentVersion)
at BusinessV1Client.CheckForUpdate(String currentVersion)
Is there something wrong with my config?
<system.serviceModel>
<services>
<service name="SP.WebWCF.Business_v1">
<endpoint
address="https://services.mydomain.com"
binding="basicHttpBinding"
bindingConfiguration=""
contract="SP.WebWCF.IBusiness_v1"
listenUri="/" isSystemEndpoint="true" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Ok, so your did show the server config, but you never really told us what the error is - you show the stack trace - but not the error message.....
Anyway, looking at your service config, one thing seems a bit odd - your service address:
address="https://services.mydomain.com"
binding="basicHttpBinding"
Typically this would either be something like
address="https://services.mydomain.com/MyServiceVirtualDir/MyService.svc"
if you're hosting your service inside IIS, or something like
address="https://services.mydomain.com/MyService"
if you're self-hosting in a Windows NT service or something.
Can you double-check your address - are you 100% sure it's correct??
Update: also, you're using https://, however, you're not showing any security-settings in your service config. Just for test: can you invoke your service when you change the service address in the config to just http:// ??