How to change address of WSDL? - wcf

I host simple WCF service in IIS in web application.
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="SimpleServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="SimpleServiceBehavior" name="SimpleService">
<endpoint address="" binding="basicHttpBinding" contract="ISimpleService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
When I run service hosted on http://projects.mydomain.com/application/SimpleService.svc it shows default service page with link to WSDL:
svcutil.exe http://terminal.mydomain.local/application/SimpleService.svc?wsdl and so on
Clients can create service reference but fail to execute methods because cannot resolve host name terminal.mydomain.local
The question is why server name is its local name 'terminal.mydomain.local' instead of 'projects.mydomain.com' ?

I found answer: http://forums.asp.net/p/1096811/1659596.aspx
I needed to change host headers.

Related

I'm not able to run WCF service on IIS 5.1

I have WCF service that works fine on VS2008's Development Server, but after I deployed it on IIS 5.1 and ran the following error message comes up:
This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.
Parameter name: item
The appropriate section in web.config file looks as following:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="Parus.ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="Parus.ServiceBehavior" name="Parus.Service">
<endpoint address="" binding="basicHttpBinding" contract="Parus.IService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
I've tried to follow this article:
http://blogs.msdn.com/b/rampo/archive/2008/02/11/how-can-wcf-support-multiple-iis-binding-specified-per-site.aspx
But it's not working.
Does anybody know to resolve this issue?
Goran

how to configure wcf endpoints?

<system.serviceModel>
<services>
<service
name="myClass.IService1" behaviorConfiguration="myService">
<endpoint
name="ep1"
address="http://localhost:57582/Service1.svc"
contract="IService1"
binding="basicHttpBinding"
/>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="myService">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
but still i am getting the following error::
Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata.
your service name IService1 - this looks like it might in fact be
the contract. If you are using the normal templates then remove the
I from IService1
If you are IIS hosting you can remove the address as the location of the .svc file is automatically the address.
The contract needs to be fully qualified including the namespace of the contract interface
with this in place your metadata should be served from <.svc file location>?wsdl

Metadata doesn't appear

I'm trying to create a WCF service, but the metadata doesn't appear, i try:
<system.serviceModel>
<services>
<service
name ="MyNamespace.IMyContract"
behaviorConfiguration="mex">
<endpoint
address = ""
binding = "wsHttpBinding"
contract = "MyNamespace.IMyContract"
/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="mex">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
I try to access with http://MyServer/receptor.svc but shows that Metadata publishing for this service is currently disabled. and http://MyServer/mex shows 404, why? What am i doing wrong?
OBS1: i publish my service in IIS7.5 on Windows 7.
OBS2: if i remove behaviorConfiguration="mex" the metadata works, but with basicHttpBinding not with wsHttpBinding.
I forget to put:
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />

Extending timeout and message size in WCF service generated by Biztalk 2006 R2

I'm generating WCF service using Biztalk. The code I get is this:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviorConfiguration">
<serviceDebug httpHelpPageEnabled="true" httpsHelpPageEnabled="false" includeExceptionDetailInFaults="false" />
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" externalMetadataLocation="" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<!-- Note: the service name must match the configuration name for the service implementation. -->
<service name="Microsoft.BizTalk.Adapter.Wcf.Runtime.BizTalkServiceInstance" behaviorConfiguration="ServiceBehaviorConfiguration">
<endpoint name="HttpMexEndpoint" address="mex" binding="mexHttpBinding" bindingConfiguration="" contract="IMetadataExchange" />
<!--<endpoint name="HttpsMexEndpoint" address="mex" binding="mexHttpsBinding" bindingConfiguration="" contract="IMetadataExchange" />-->
</service>
</services>
</system.serviceModel>
Maybe it's not the most beautifull configuration, but it works. The problem is I don't know how to modify timeouts and message max size, because it has only mex endpoint. I'm surprised how this works at all with just mex endpoint.
So two questions are:
Why does this works at all?
What should I add to extend timeouts and message size?
I seem to recall the reason those settings aren't in the config file is because the binding configuration is stored in the receive location / send port settings in biztalk itself. So the way to set them is to change them from the receive location adapter configuration.

WCF NetTcpBinding with mex

I'm trying to publish a wcf service using nettcpbinding. I want to publish metadata, using ?wsdl.
I added the following line to the config file:
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
but I can't see the wsdl in my browser. what did I do wrong?
Thanks.
Edit: Here is the relevant part of my config file:
<system.serviceModel>
<services>
<service name="wcfcheck.service1" behaviorConfiguration="wcfcheck.Service1Behavior">
<endpoint address="" binding="netTcpBinding" contract="wcfcheck.Iservice1"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="wcfcheck.Service1Behavior">
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
I might not be accessing the right URL. I tried both http://localhost:51159/Service1.svc?wsdl and http://localhost:51159/Service1.svc/mex?wsdl, and without the '?wsdl'.
You need to use the <serviceMetadata> element.
<behaviors>
<serviceBehaviors>
<behavior name="metadataSupport">
<!-- Enables the IMetadataExchange endpoint in services that -->
<!-- use "metadataSupport" in their behaviorConfiguration attribute. -->
<!-- In addition, the httpGetEnabled and httpGetUrl attributes publish -->
<!-- Service metadata for retrieval by HTTP/GET at the address -->
<!-- "http://localhost:8080/SampleService?wsdl" -->
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
</behavior>
</serviceBehaviors>
</behaviors>
You need to publish service metadata via http for wsdl. Add the following tag to the <system.serviceModel> tag of your config file
<behaviors>
<serviceBehaviors>
<behavior name = "MetadataBehavior">
<serviceMetadata httpGetEnabled = "true"/>
</behavior>
</serviceBehaviors>
</behaviors>
You will also need to specify an http address where the service metadata in wsdl will be available from. Add this to the <service> node of your config file :
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8001" />
<add baseAddress="http://localhost:8000/Service1" />
</baseAddresses>
</host>
Then if you go to http://localhost:8000/Service1?wsdl, you should see the wsdl for your service.
You can try mexTcp binding and make sure your base address starts with net.tcp://.....