I have successfully configured 3 endpoints for my prototype service. The endpoints are basicHttpBinding, wsHttpBinding, and webHttpBinding. The only glitch I have at the moment is in the WCFTestClient. When I point it to my service it lists the first two, but not the webHttpBinding. I can test the REST endpoint through my browser and it works just fine. Here's my config:
<system.serviceModel>
<services>
<service behaviorConfiguration="serviceBehaviour" name="VMDServices.VMDService">
<endpoint binding="webHttpBinding"
address="rest" behaviorConfiguration="webBehaviour" contract="VMDServices.IService1">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint binding="basicHttpBinding"
address="basic" bindingConfiguration="basicBinding" contract="VMDServices.IService1">
</endpoint>
<endpoint binding="wsHttpBinding"
address="ws" bindingConfiguration="wsBinding" contract="VMDServices.IService1">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="basicBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None"></security>
<readerQuotas maxStringContentLength="2147483647"/>
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="wsBinding" transactionFlow="true">
<security mode="None"></security>
<reliableSession enabled="true" ordered="true" />
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="webBehaviour">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="serviceBehaviour">
<!-- 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" aspNetCompatibilityEnabled="true">
</serviceHostingEnvironment>
</system.serviceModel>
Is there any reason why I can't see the webHttpEndpoint in the WCFTestClient tool?
Cheers,
Dany.
It's because web endpoints (unlike SOAP ones) do not expose metadata, so the test client doesn't know about it when it downloads the WSDL for the service. Unlike SOAP, which has well-defined formats for exposing metadata (WSDL, MEX), web (a.k.a. REST) endpoints do not.
That's the short story. If you want to know more details, I wrote a blog post about it at http://blogs.msdn.com/b/carlosfigueira/archive/2012/03/26/mixing-add-service-reference-and-wcf-web-http-a-k-a-rest-endpoint-does-not-work.aspx
The following is a list of features not supported by WCF Test Client:
• Types: Stream, Message, XmlElement, XmlAttribute, XmlNode, types that implement the
IXmlSerializableinterface, including the related XmlSchemaProviderAttribute attribute, and the XDocument and XElement types and the ADO.NET DataTable type.
• Duplex contract.
• Transaction.
• Security: CardSpace , Certificate, and Username/Password.
• Bindings: WSFederationbinding, any Context bindings and Https binding, WebHttpbinding (Json response message support).
Source: http://msdn.microsoft.com/en-us/library/bb552364.aspx
try adding the "mexHttpBinding" endpoint that exposes the metadata
Related
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();
I have a wcf restful service up and running. I can issue Get/Post with no issues if I start a webservice using WebServiceHost. I tried moving the wcf service to IIS 7.5 on my local box and I can't seem to get it going.
I keep getting the following error anything I try to call anything from from the wcf service: (http://wp9dbytr1k1:8081/service.svc/AnythingHereForGETorPUT). I've tried in virtual directory/Appliances and I get the same issue.
The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
if I call the svc file directly (http://wp9dbytr1k1:8081/service.svc), its happy and tells me
"You have created a service.
To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:
svcutil.exe http://wp9dbytr1k1:8081/FUU/service.svc?wsdl"
The strack trace from Trace viewer hasn't help: Sorry have to add a link, not allowed to post images yet. (ImageLink)
Here's my web.config
<system.serviceModel>
<bindings>
<mexHttpsBinding>
<binding name="NewBinding0" />
</mexHttpsBinding>
<webHttpBinding>
<binding name="WebBinding">
<readerQuotas maxDepth="524288" maxStringContentLength="524288"
maxArrayLength="524288" maxBytesPerRead="524288" maxNameTableCharCount="524288" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" />
</security>
</binding>
</webHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="StoredProcBehaviors" name="StoredProcService.DataRetreivalService">
<endpoint address="" binding="webHttpBinding" bindingConfiguration="WebBinding"
contract="StoredProcService.IDataRetreivalService">
<identity>
<dns value="locahost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
contract="StoredProcService.IDataRetreivalService" />
<host>
<baseAddresses>
<add baseAddress="http://WP9DBYTR1K1:8081/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="StoredProcBehaviors">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
For obvious reasons, this feels like IIS setup since it works with WebServiceHost. I've googled the errors/tutorials on how to set this up and everything seems good to me.
Any suggestions?
Thanks
To create a REST endpoint in WCF, you need, in addition to using the WebHttpBinding, to have an endpoint behavior with on it.
<system.serviceModel>
<services>
<service behaviorConfiguration="StoredProcBehaviors" name="StoredProcService.DataRetreivalService">
<endpoint address="" binding="webHttpBinding" bindingConfiguration="WebBinding" behaviorConfiguration="REST"
contract="StoredProcService.IDataRetreivalService">
<identity>
<dns value="locahost" />
</identity>
</endpoint>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="REST">
<webHttp/>
</behavior>
<endpointBehaviors>
</behaviors>
</system.serviceModel>
Another option is to use the WebServiceHostFactory in the .svc file, which works like the WebServiceHost. In this case you don't even need the system.serviceModel section in web.config.
<% #ServiceHost Service="StoredProcService.DataRetreivalService" Factory="System.ServiceModel.Activation.WebServiceHostFactory" Language="C#" debug="true" %>
I currently have a WCF service with webHttp bindings, im attempting to increase the max size that can be inputted to the service by overriding the default settings in config, i have tried doing something like
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="webHttp" >
<security mode="Transport">
<transport clientCredentialType =
"None"
proxyCredentialType="None"
realm="string" />
</security>
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="PrimeStreamInfoServices.Service1" behaviorConfiguration="PrimeStreamInfoServices.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="" binding="webHttpBinding" contract="PrimeStreamInfoServices.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.
-->
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="PrimeStreamInfoServices.Service1Behavior">
<!-- 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>
<diagnostics>
and setting various other properties pertaining to message size but none seems to be working, can one even change the m essage size of a webHttp binding?
Any suggestions? Thanks!
There's a multitude of settings that might have an influence depending on your settings - try this:
<bindings>
<webHttpBinding>
<binding name="LargeWeb"
maxBufferPoolSize="1500000"
maxReceivedMessageSize="1500000"
maxBufferSize="1500000">
<readerQuotas
maxArrayLength="656000"
maxBytesPerRead="656000"
maxDepth="32"
maxNameTableCharCount="656000"
maxStringContentLength="656000"
/>
</binding>
</webHttpBinding>
</bindings>
By defining your "version" of the webHttpBinding and setting all those parameters to higher values, you should be able to get through any message size (almost).
Mind you: this does open up your system to the potential of being flooded with huge messages and thus be brought down to its knees (classic denial-of-service attacks) - that's the reason these limits are set fairly low - by design and on purpose.
You can change them to higher values - just be aware what you're doing and what the security risks are, if you do!
Marc
PS: In order to make use of these settings, you of course have to reference that binding configuration in your server and client side configs:
<client>
<endpoint address="http://localhost"
binding="webHttpBinding" bindingConfiguration="LargeWeb"
contract="IMyService" />
</client>
<services>
<service>
<endpoint address="http://localhost"
binding="webHttpBinding" bindingConfiguration="LargeWeb"
contract="IMyService" />
</service>
</services>
Setting Max Message and buffer size for WCF Rest services webhttpbinding
<bindings>
<webHttpBinding>
<binding maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="200" maxStringContentLength="83886089" maxArrayLength="163841" maxBytesPerRead="2147483647" maxNameTableCharCount="16384"/>
</binding>
</webHttpBinding>
</bindings>
If you are using [DataContract] decorator in your model, you need to add yhe dataContractSerializer into your web.config
Example:
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpsGetEnabled="false" httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
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?