My WCF Service uses wsHttpBinding and works fine from the client when the service is gerenated by the client using the default options as follows:
RServiceClient R = new RServiceClient();
However, at some point I'll need to be able to specify the location of the service, presumably by changing the endpoint address as follows:
RServiceClient R = new RServiceClient();
R.Endpoint.Address = new EndpointAddress(new Uri "http://xxx.xxxx.xxx:80/RServer/RService.svc"));
However, when I do specify the exact endpoint, I get a SecurityNegotiationException:
System.ServiceModel.Security.SecurityNegotiationException was unhandled
Message="The caller was not authenticated by the service."
Source="mscorlib"....
The WCF service runs on IIS and has anonymous access enabled under IIS admin. Also, this error occurs when the client is run from the same machine as the service under an admin account - I havn't got to the scary part of running it over the net yet!
Any Ideas?
By default, wsHttpBinding uses Windows authentication. I'm not sure how hosting in IIS affects that scenario.
If you don't want security turned on, you can add an element for security and set the mode element to "None" to the config on both ends to turn off the default setting.
I think this may do the trick -- I've added the section for wsHttpBinding and set the bindingConfiguration of your service to point to the newly added binding properties:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttpBind">
<security mode="None">
<transport clientCredentialType="None" protectionLevel="EncryptAndSign" />
<message clientCredentialType="None" algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehavior"
name="RService">
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="wsHttpBind"
name="RService"
contract="IRService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
name="MetadataExchange"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<!-- 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>
</system.serviceModel>
check this from your config :
...
<identity>
<dns value="localhost" />
</identity>
...
afaik wsHttpBinding has message security turned on by default.
and when it checks against the dns value "localhost" it fails.
Are you using MessageSecurity with certificates? this could be a certificate issue (wrong hostname, self-signed certificate not installed, etc..)
Here is my Service configuration information, i'm using wshttpbinding:
<system.serviceModel>
<services>
<service behaviorConfiguration="ServiceBehavior" name="RService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration=""
name="RService" contract="IRService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" name="MetadataExchange"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<!-- 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>
</system.serviceModel>
Deleting the identity block didn't work, although did give me an idea:
If I change the endpoint address from:
R.Endpoint.Address = new EndpointAddress(new Uri("http://bigpuss.homeip.net/RServer/RService.svc"));
to
R.Endpoint.Address = new EndpointAddress(new Uri("http://localhost/RServer/RService.svc"));
then everything works fine! Soo, its obviously upset about the nonlocal url address. Are there any other areas in the configuration where security is set up?
Related
i know too many duplicates for this message but please give your lights here..
I am getting an entity from WCF Customer which contains a photo field in base64. I have no problem to get it on my android device
when i update lets say the phone of this customer and upload the entity in in wcf i get an error Entity too large
Please also note that..
If i debug my WCF from the solution right click debug and try to read this entity i am getting the error maximum message size quota for incoming messages has been exceeded
The strange is how is possible that i can read the entity on device but i cannot read it when debugging and i cannot upload it back when i save.
3 different things here..
When i connect from code behind to my service i do it like this
ServiceEndPoint = New ServiceModel.EndpointAddress(New Uri("http://MyIpAddress:MyPort/WcfServiceLibrary1.Service1.svc"))
Dim Binding As New BasicHttpBinding
Binding.MaxReceivedMessageSize = 20000000
MyService = New ServiceReference1.Service1Client(Binding, ServiceEndPoint)
and this is my Configuration
<system.serviceModel>
<client>
<endpoint name="basicEndpoint"
address="http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/"
binding="basicHttpBinding"
bindingConfiguration="basicHttp"
contract="WcfServiceLibrary1.IService1"
>
</endpoint>
</client>
<services>
<service name="WcfServiceLibrary1.Service1" behaviorConfiguration="ServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8452/Design_Time_Addresses/WcfServiceLibrary1/Service1/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="http://localhost:8542/Design_Time_Addresses/WcfServiceLibrary1/Service1/" binding="basicHttpBinding" bindingConfiguration="basicHttp" contract="WcfServiceLibrary1.IService1">
<!--Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.-->
<!--<identity>
<dns value="localhost" />
</identity>-->
</endpoint>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<!--<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />-->
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="basicHttp" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
<readerQuotas maxDepth="32" maxStringContentLength="20000000" maxArrayLength="20000000" />
<security mode="None"></security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<!-- To avoid disclosing metadata information,
set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<!-- 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>
Try changing all values of property in binding to 2147483647.
Try programmatically setting value as follows
BasicHttpBinding binding = new BasicHttpBinding() {
MaxBufferSize = 2147483647,
MaxReceivedMessageSize = 2147483647
};
I am trying to develop a WCF service and host it in IIS. But when I try to consume service, I get this error.
Could not find default endpoint element that references contract 'ServiceReference1.IService1' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
I have tested the WCF service using the WCF Test Client and I was able to invoke it successfully.
But the same doesn't work when I consume it. Kindly help me to sort out this.
web.config I have used in WCF:
<!--WCF web config-->
<system.serviceModel>
<services>
<service name="ProductServiceLibrary.RuelaService">
<endpoint address="" binding="wsHttpBinding" contract="RuelaService.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
When I consume the WCF service, I make use of this app.config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" />
</basicHttpBinding>
</bindings>
<client>
<!--URL where I have hosted my WCF http://localhost:9999/Service1.svc-->
<endpoint name="BasicHttpBinding_IService1"
address="http://localhost:9999/Service1.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1"
contract="ServiceReference1.IService1" />
</client>
</system.serviceModel>
[1]: http://i.stack.imgur.com/djQoN.png
The service appears to be exposing a contract that differs to the client configuration.
Service:
<endpoint address="" binding="wsHttpBinding"
contract="RuelaService.IService1">
Client:
<endpoint name="BasicHttpBinding_IService1"
address="http://localhost:9999/Service1.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1"
contract="ServiceReference1.IService1" />
So there is a mismatch somewhere.
i have a problem.
I tried to access to the wcf web service from an application ASP.net MVC, I got this exception when I am calling the method.
There was no endpoint listening at the URI that could accept the
message. This is often caused by an incorrect address or SOAP action.
See InnerException, if present, for more details.
this is my code
var client = new DSServiceClient();
client.Methode();
service model section of web.config
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IDSService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="localhost:1695/Service1.svc"; binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IDSService" contract="ServiceReference1.IDSService" name="BasicHttpBinding_IDSService" />
</client>
</system.serviceModel>
Check that the URL you are using is accessible from asp.net mvc site. If you are using http binding you can copy and paste url into browser on the server where your site is deployed. The URL should be in web.config file in the root folder of your site.
Are you using IIS 7 to host? If So you can go to your site, enable directory browsing (temporarily), click on the browse link on the right side of IIS manager, select the service class ("something.svc") and it should pop up in a browser. At that point you can copy the URL from the browser and replace localhost with the server name. You can even go on to click on the top link on that page to get to the WSDL. If there is a problem you may get an error message that may be more helpful.
this is my web.config of the service
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpEndpointBinding">
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="DSWebService.Service1Behavior"
name="DSWebService.Service1">
<endpoint address="" binding="wsHttpBinding"
contract="DSWebService.IDSService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:1695/DSWebService" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DSWebService.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false 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="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
and this is my web.config of the client:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IDSService" />
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:1695/Service1.svc" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IDSService" contract="IDSService"
name="WSHttpBinding_IDSService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
and the 2 project should be on the same solution and after we do add reference :
DSServiceClient client = new DSServiceClient();
client.Methode();
This is a follow on from this question I've configured the a WCF service running in IIS (From within Visual Studio 2010) to run one Web service and one net.tcp service. After a lot of hacking I've managed to get the Web Service to load into the WCF test client, but I can't get the Net.Tcp service to load into the test client.
Here is my Web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="ServerService" behaviorConfiguration="ServerServiceBehaviour">
<endpoint address="ServerService.svc"
binding="netTcpBinding"
bindingConfiguration="DefaultNetTcpBindingConfig"
name="NetTcpEndPoint"
contract="IServerService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex"
binding="mexTcpBinding"
contract="IMetadataExchange"
bindingConfiguration="mexTcpBinding"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8523/"/>
</baseAddresses>
</host>
</service>
<service name="MyWebService" behaviorConfiguration="WebServiceBehaviour">
<endpoint address="MyWebService.svc"
binding="wsHttpBinding"
bindingConfiguration="DefaultWSBinding"
name="MyWSEndPoint"
contract="IMyWebService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"
bindingConfiguration="mexHttpBinding"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8523/"/>
</baseAddresses>
</host>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="DefaultNetTcpBindingConfig"
maxConnections="5"
portSharingEnabled="true" >
</binding>
<!--<binding name="mexBinding"
portSharingEnabled="true">
<security mode="None"></security>
</binding>-->
</netTcpBinding>
<wsHttpBinding>
<binding name="DefaultWSBinding"/>
</wsHttpBinding>
<mexTcpBinding>
<binding name="mexTcpBinding"/>
</mexTcpBinding>
<mexHttpBinding>
<binding name="mexHttpBinding"/>
</mexHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServerServiceBehaviour">
<!-- 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="false"/>
</behavior>
<behavior name="MexBehaviour">
<serviceMetadata httpGetEnabled="true" policyVersion="Policy15"/>
</behavior>
<behavior name="WebServiceBehaviour">
<!-- 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="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
When I run the Visual Studio Debugger to publish the Service I can access the web service by entering the following url into the WCF Test Application:
http://localhost:8523/MyWebService.svc
But if I enter the following Url into the WCF Test Application I get an error:
net.tcp://localhost:8523/ServerService.svc
Here is the Error I see:
Error: Cannot obtain Metadata from
net.tcp://localhost:8523/ServerService.svc If this is a Windows (R)
Communication Foundation service to which you have access, please
check that you have enabled metadata publishing at the specified
address. For help enabling metadata publishing, please refer to the
MSDN documentation at
http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange
Error URI: net.tcp://localhost:8523/ServerService.svc Metadata
contains a reference that cannot be resolved:
'net.tcp://localhost:8523/ServerService.svc'. You have tried to
create a channel to a service that does not support .Net Framing. It
is possible that you are encountering an HTTP endpoint. Expected
record type 'PreambleAck', found '72'.
Having read this question is it possible that the webserver in VS 2010 doesn't support net.tcp binding?
It looks like the issue I was seeing was that the Web Server in Visual Studio 2010 doesn't support Net.Tcp Binding.
I've got slightly further by installing IIS7 (IIS6 doesn't support Net.Tcp either) and telling visual studio to use IIS instead.
You can do this by going to the properties page of your service and selecting the "Web Tab" select the Use Local IIS Web Server radio Button and configure the webserver.
You can also tell is to start an external program on this tab to make it start the WcfTestClient.exe and pass in the URL to your services as command line parameters.
I'm still having issues but they are different issues so I'll open another question.
I have a simple WCF REST based service deployed (development ofcourse) using SSL. I am trying to make it work with basic authentication but quite frankly am getting nowhere with it.
IIS 6.0
REST based - Using webHttpBinding
Here is what my web.config looks like ... just the relevant portions:
<system.serviceModel>
<services>
<service behaviorConfiguration="ThisTestService.MyTestServiceBehavior"
name="ThisTestService.MyTestService">
<endpoint address="" binding="webHttpBinding" bindingConfiguration="Secure" behaviorConfiguration="WebBehavior" contract="ThisTestService.IMyTestService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" bindingConfiguration="Secure" contract="IMetadataExchange"></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ThisTestService.MyTestServiceBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="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>
<endpointBehaviors>
<behavior name="WebBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="Secure">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic"/>
</security>
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
I have Anonymous authentication turned off in IIS on the virtual directory for the WCF service and Basic authentication is turned on.
When I try to access it say using https://localhost/ThisTestService/MyTestService.svc, I cannot get to it. It gives the "Could not find a base address that matches scheme http for the endpoint with binding WebHttpBinding. Registered base address schemes are [https].".
I've googled a lot but so far all my attempts to understand and fix the issue have been in vain. If I use anonymous authentication then I have no issues however I need to use basic authentication.
Any help is greatly appreciated. Thanks.
You need to turn on https for the virtual directory in which you are hosting the service. (As explained in the last para of this article: http://msdn.microsoft.com/en-us/library/aa751792.aspx)