WSDL file is missing for WCF WebService - c#

I created simple wcf service with default functionality and hosted in IIS7. Its working fine and rendering data to the client. But when I try to click on wsdl link in the service its showing "Page cannot be displayed".Let me know what will be the problem
.
When I try to click the link below (http://win-nsms.smsserver.com/VirtualFolder/MyService.svc?wsdl), WSDL file is not getting displayed in the browser. Instead I am getting "The page cannot be displayed" error in the page
Now If I change the "win-nsms.smsserver.com" to "localhost" in the URL, WSDL file is getting displayed.
Yes I added behaviour configuration in my config as follows
<system.serviceModel>
<services>
<service name="WcfServiceSample.Service1" behaviorConfiguration="WcfServiceSample.Service1Behavior">
<endpoint address="" binding="wsHttpBinding" contract="WcfServiceSample.IService1">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment>
<baseAddressPrefixFilters>
<add prefix="http://win-nsms.smsserver.com"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<behaviors>
<serviceBehaviors>
<behavior name="WcfServiceSample.Service1Behavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>

Have you allowed retrieval of service meta data?
In the behaviours section of your config file, add a new behaviour like this:
<behaviors>
<serviceBehaviors>
<behavior name="HttpGetMetadata">
<serviceMetadata httpGetEnabled="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
Then tell your service to use this behaviour:
<system.serviceModel>
<services>
<service name="MyService"
behaviorConfiguration="HttpGetMetadata">
....
This is telling your service to allow the service metadata (the WSDL) to be retrieved via http. To confirm you can browse to the appropriate URL.

Is "mymachinename.domainname.com" added as a hostmask in IIS for the site?
You may need to setup the base address for the service.
<serviceHostingEnvironment>
<baseAddressPrefixFilters>
<add prefix="http://mymachinename.domainname.com"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
I had a similar problem where the service was working 100% for domain.com but not www.domain.com. I had to setup the latter as a redirect to the former and set the base address to the former.
HTH!

Did you enable WDS exposure? Standard settings dont show the WDSL.

Related

Hide one WCF service in wsdl

I have my own wsdl with few methods.
They are visible in e.g. SoapUI.
I want to implement new service, but I want to hide it from wsdl, but I want to call it.
Is that possible?
Yes it is. Just tell WCF you do not want to expose metadata in the service configuration:
<system.serviceModel>
<services>
<service behaviorConfiguration="MyServiceBehavior" name="MyService">
<endpoint address="http://MyService:8888" binding="wsSomeBinding" contract="IMyServiceContract" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>

IIS hosted WCF Service return HTTP 400 Bad Request

I have been searching for hours, but I could not find the solution. I will explain briefly.
I am learning WCF Services. I have just created a service and browse it. Here is the config file:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="EmployeeServiceBehaviour">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="EmployeeServiceBehaviour" name="EmployeeConfiguration">
<endpoint address="http://localhost:2005/EmployeeService.svc" binding="basicHttpBinding"
bindingConfiguration="" contract="IEmployeeConfiguration" />
</service>
</services>
</system.serviceModel>
<system.web>
<compilation debug="true"/>
</system.web>
<system.webServer>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
When browse it from Visual Studio there seems no problem. It works perfectly.
Second, I am trying to publish it on IIS. What I am doing is this:
I publish the service to a folder and add this service to IIS.
I select port 3006 as a port.
Below its config file. Note that I also changed port inside config to 3006
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="EmployeeServiceBehaviour">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="EmployeeServiceBehaviour" name="EmployeeConfiguration">
<endpoint address="http://localhost:3006/EmployeeService.svc" binding="basicHttpBinding"
bindingConfiguration="" contract="IEmployeeConfiguration" />
</service>
</services>
</system.serviceModel>
<system.web>
<compilation/>
</system.web>
<system.webServer>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
And I am waiting to run smoothly but:
IIS gives me a blank page from Chrome
And HTTP 400 Bad Request from Explorer
Lastly, if I remove address part from config file everything works well. But other confused thing is that, on my other computer after above scenario(address provided) I can reach the service. So, I really tired of searching why this is working on one computer and not working on another one. Could someone explain it to me?
I know it is a bit longer, but I have to explain it clearly.
Thanks
According my searches, I should not provide an address.
msdn.microsoft.com/en-us/library/aa751792(v=vs.110).aspx
You must always use relative endpoint addresses for IIS-hosted service
endpoints. Supplying a fully-qualified endpoint address (for example,
localhost/MyService.svc) can lead to errors in the deployment of the
service if the endpoint address does not point to the IIS-application
that hosts the service exposing the endpoint. Using relative endpoint
addresses for hosted services avoids these potential conflicts.
I think this will solve your problem:
Add this endpoint to your service:
<endpoint address="mex" binding="mexHttpBinding"
bindingConfiguration="" contract="IMetadataExchange" />
And change the name attribute of the service to your service class's full name:
<service behaviorConfiguration="EmployeeServiceBehaviour"
name="Namespace.EmployeeConfigurationClass">
Hope that is enough
This may be of help. ive just spent over 2 hours trying to get this working. i use FF and its set as the default browser.
in FF it was adding a / on the end of my URL
http://services.tester.dev/VehicleFeedService.svc/
which returned a NetworkError: 400 Bad Request
however in IE or chrome, it doesnt put the / on the end and it works fine.
one thing to note.. even in FF which was giving me a 400 bad request, the ?wdsl did work
http://services.tester.dev/VehicleFeedService.svc?wsdl
it appears that the / was causing the issue
You can try fiddler and also try the svcTracer which may give you lot of debugging information on the top of it you can also use includeExceptionDetailInFaults=true flag on the server but its important to flag that its not always right to send this information to the client specially if client is an external entity. With this warning following is the hint how to use it.
<serviceBehaviors>
<behavior name="ServiceBehavior">
....
<serviceDebug includeExceptionDetailInFaults="true" />
....
</behavior>
</serviceBehaviors>
Happy debugging :)

WCF Service - Endpoint is not showing

I have a WCF Service where it has one endpoint and I have the service contract and operation contract setup in the config file but when I run the service, it cannot find the endpoint although I configured it in the web.config.
This service will be setup in IIS so I have no base address setup.
The ServiceContract has a configuration name of agent_port_type and the service behavior has a configuration name of agent_service. I am using basicHttpBinding.
Below is a copy of part of my config file:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ETAOutboundServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="Metadata">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="ETAOutboundServiceBehavior" name="agent_service">
<clear />
<endpoint address="" name="agent_interface" binding="basicHttpBinding" contract="agent_port_type"
listenUriMode="Explicit" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"
listenUriMode="Explicit" />
</service>
</services>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Any help would be appreciated. I had it working on a different service fine but then I used svcutil to create agent_port_type and it is not working.
You should try simplifying the config to something that Works, then add extra options as need.
Start With:
Remove Clear tag
Remove all References to HTTPS
Remove listenURIMode
Add an address for the endpoint
Check the IIS log that you are calling the service that you think you are calling
Add a syntax error to Your config and check that it fails (to make sure that the config file you are editing is the one being used)

Metadata contains a reference that cannot be resolved .

Following is my WCF configuration. I published it in IIS and trying to connect to it from a Windows forms client.
<system.serviceModel>
<client />
<bindings>
<wsHttpBinding>
<binding name="BindingConfiguration">
<security>
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="Service" behaviorConfiguration="BehaviorConfiguration">
<endpoint address="" binding="wsHttpBinding" name="wsBinding" contract="WCFHttps.IService1" bindingConfiguration="BindingConfiguration"/>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name= "BehaviorConfiguration">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Windows"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<!--<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />-->
It throws an error while trying to add service reference in the test client.
The HTML document does not contain Web service discovery information.
Metadata contains a reference that cannot be resolved: '****/Service1.svc?wsdl'.
Content Type application/soap+xml; charset=utf-8 was not supported by service ****/Service1.svc?wsdl. The client and service bindings may be mismatched.
The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..
If the service is defined in the current solution, try building the solution and adding the service reference again.
I have also granted read/write permissions for IIS_USRS over C:\Windows\Temp folder but still the problem persists. Can anyone suggest what's wrong here.
Thanks.
cause:
Cause of this error is simple when you try to refer the WCF service IIS tried to access C:\Windows\Temp folder. If ASP.NET or IIS_IUSER(based on the windows version) account doesn’t have access to this folder you will see this error.
Solution:
Add ASP.NET or IIS_USER account to this folder or give admin rights to the user account you are running your application.
Configuring Tracing
http://msdn.microsoft.com/en-us/library/ms733025.aspx
In my case wrong namespace was specified in web.config file. It has to be same as namespace of your .svc file:
<service name="NAMESPACE.SvcFileName">
<endpoint contract="NAMESPACE.IContractName" />
</service>
Example:
<service name="MyNameSpace.FileService">
<endpoint contract="MyNameSpace.IFileService" />
</service>
(Unrelevant tags ommited in these samples)

Why do I have to specify my address in my WCF configuration (it is actually working)

I have set up a wcf service and when I browse to the .svc file I am presented with a screen that says...
You have created a service.
So I know that the service is running successfully. However I have looked in the configuration and it does not actually have an address.
<system.serviceModel>
<services>
<service behaviorConfiguration="CountryProvinceBehavior" name="CountryProvinceWCFService">
<endpoint address="" binding="webHttpBinding" contract="ICountryProvinceWCFService" behaviorConfiguration="CountryProvinceBehavior"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="CountryProvinceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="CountryProvinceBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
I then wrote a console app to test the service.
I got thr url from the browser and added a 'Service Reference' from a console application I was expecting the project to create enpoint defintions in my configuration file. And then when I create a client I could load up one of these configs but they aren't there....
You don't have to specify the address in configuration, although in this case you do specify the address for the endpoint (""). That means that WCF will use it as an address relative to the service base address. If the service is hosted in IIS, then it'll be the address of the .svc file. If the service is self-hosted (i.e., using ServiceHost directly), then the address will be the one passed to the ServiceHost constructor.

Categories

Resources