Metadata exposed but WSDL not found - wcf

I am having trouble with my WCF service which somehow fails to expose/publish a WSDL definition. I have already gone through the MSDN tutorial on exporting Metadata. Also have I searched at least for some hours but the majority of people have different/simpler problems than me.
I am pretty sure my config file is correct so I would be thankful for anybody who could suggest other places I can look for?
My service is generally running and I can access it on localhost, where I get the standard page for the WCF services (message displaying "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:" etc.).
When I try to access the *?wsdl extension my browser tells me that the page couldn't be found.
When I try to test the service in soapUI it tells me that there is something wrong with the WSDL.
So, I hope this gives anybody an idea of what my problem is and I would be really thankful for any help.
Cheers

Have you specified httpGetEnabled in your serviceBehavior?
<behaviors>
<serviceBehaviors>
<behavior name="SubscriberOperationsBehavior">
<serviceMetadata httpGetEnabled="true"
httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
You can also create a mex endpoint.
Add the following endpoint to your service configuration:
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />

Related

Howto: WCF service external to solution (not domain!) with AutoCompleteExtender

I've coded a WCF service that is external to the solution I wish to use it in. I'm doing this so that I can have one service that's reusable across many solutions. We've already duplicated this service many times as an asmx integral to the solution and it's not a good maintenance scenario. I'm finally able to have time to tackle gettign this working the right way. Any help will be greatly appreciated! All the posts I've seen about this take me in circles. My solution (and the service) is in VS2010, Framework 4.0, vb.net.
When using the webHttpBinding binding in the endpoint, when I add the service to my solution the reference is getting added, but web.config does not get added with the system.serviceModel configuration group that is needed. All the articles I can find talk about making the service part of the solution but that is what I'm trying to avoid.
Any ideas? Here is the system.serviceModel section of my service's web.config:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="AspNetAjaxBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<!-- 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" />
<services>
<service name="Com.mydomain.Services.WCF_ACE.ACE">
<endpoint address=""
behaviorConfiguration="AspNetAjaxBehavior"
binding="webHttpBinding"
contract="Com.mydomain.Services.WCF_ACE.I_ACE" />
</service>
</services>
So you are trying to use a wcf service you built. It looks like clients section is missing in the attached config file.
And client configuration is always going to be different from service config. And you can add that manually to the client solution.

Incorrect address when service is hosted in Azure

I have hosted a WCF service on Azure at http://voraservice.cloudapp.net/MyPushService.svc. The problem is when I connect through client, it gives me that no endpoint found at the given address:
http://rd00155d3425e0/MyPushService.svc
I dont know how this random servername came here and am trying to figure out since few hours how to remove this random server name and put the actual location of the WCF hosted on the cloud. Any pointers to solutions are appretiated!
Update: I saw this KB article - http://support.microsoft.com/kb/971842/
But when I try to update for Win7 its says hte update is not for my computer.
Initially I was redirected to this KB - http://support.microsoft.com/kb/971842/ but this dint help me on my Windows 7 machine.
Finally I was able to resolve this by adding useRequestHeadersForMetadataAddress tag inside serviceBehaviors tag.
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ShoutboxWebRole.ShoutsBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<useRequestHeadersForMetadataAddress/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
...
</services>
</system.serviceModel>
May sound like a manual instruction, but please check the config of consuming application. Often it is pointing to wrong direction. Here is a similar problem discussed in this blog post http://junooni.wordpress.com/tag/azure-incorrect-address-no-endpoint-listening/
All the best.

Problem with WCF Hosting on Mono

I am trying to host a simple application with one .aspx, .asmx and .svc file each. I followed the below guide to achieve the hosting (since I am very new to the linux world, it took a while to understand it!):
http://www.mono-project.com/Mod_mono#Manual_Mod_Mono_Configuration
After all the hosting, I am able to access the aspx and asmx file. But when I try to access the svc file, I get the below error:
The ServiceHost must have at least one application endpoint (that does not include metadata exchange endpoint) defined by either configuration, behaviors or call to AddServiceEndpoint methods.
or
HttpListenerContext does not match any of the registered channels
I do have a pretty straight forward service endpoint defined in my web.config which looks like below:
<system.serviceModel>
<services>
<service name="TestWCFService">
<endpoint address="http://localhost/MonoTest/TestWCFService.svc" binding="basicHttpBinding"
contract="MonoTest.ITestWCFService"></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
Can you please tell me what I am doing wrong?
Note: I used MS VS 2010 to create this project and then published it. The published directory is copied to the Apache/Linux Environment. The WCF doesn't make use of any complex type. I am using Mono Version 2.8.2
UPDATE
Update: I tried using 2.10.2 Mono. This error is gone and I am now facing a new one:
XmlSchema error: Named item http://tempuri.org/:DoWork was already contained in the schema object table. Consider setting MONO_STRICT_MS_COMPLIANT to 'yes' to mimic MS implementation. Related schema item SourceUri: , Line 0, Position 0.
After weeks of R&D on this I have figured out this. For some reason, I can't get the service WSDL to work (meaning I can't access the .svc from browser). However, the service works fine when I try to access it using Channel Factory.
So I have implemented everything in Channel Factory (for my Silverlight app) and everything seems to be working fine right now. I am still not sure how to get WSDL to work but that's not too important to me as of now.

WCF 3.5 running SOAP and REST services side by side in IIS

I know that similar question was asked here :
Running SOAP and RESTful on the same URL
Hosting WCF soap and rest endpoints side by side
but didn't find an answer to my problem.
I have two custom servicehostfactories that enables Dependency Injection :
public class StructureMapSoapServiceHostFactory : ServiceHostFactory
public class StructureMapRestServiceHostFactory : WebServiceHost2Factory
The implementation details are not important here.
Then I definied two endpoints in web.config
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="mexGet">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="jsonBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<mexHttpBinding>
<binding name="mexHttpBinding" />
</mexHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="mexGet" name="ServiceImplementation.ServiceCategory">
<endpoint address="rest"
binding="webHttpBinding"
contract="Contracts.ServiceContracts.Mobile.IServiceCategory"
behaviorConfiguration ="jsonBehavior"/>
<endpoint address="soap"
binding="basicHttpBinding"
contract="Contracts.ServiceContracts.Mobile.IServiceCategory" />
<endpoint name="mexHttpBinding"
address="mex"
binding="mexHttpBinding" bindingConfiguration="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
Then I created two .svc files for each custom host factories :
ServiceCategoryRest.svc
ServiceCategorySoap.svc
I don't like it. What I would like to do is to have URL in that style :
REST : http://server:port/rest/categories/{id} which mapps to the implementation of my ServiceCategory.GetCategory(int id)
SOAP : http://server:port/soap/GetCategory?id=someId
My questions are. Do i need different svc files to activate host services ? If I need there two .svc files, how can I achieve the URI above ? I'm afraid that I should configure IIS rewriting or something but would like to avoid that.
Thanks in advance for your help.
Thomas
You can achieve what you're looking for with service routes - part of ASP.NET routing, available from ASP.NET 3.5 SP1 on up.
Check out these resources:
RESTful WCF Services with No svc file and no config
Drop the Soap: WCF, REST, and Pretty URIs in .NET 4
making a WCF REST stand-alone service exe from scratch – part 1 of 4, creating the minimal bare service
Using Routes to Compose WCF WebHttp Services
In .NET 3.5 SP1, you need to add some extra infrastructure to your web.config (web routing module etc.) - while in .NET 4, this is all already built in.
After few searches I found out that in fact I don't need two different .svc files and two different ServiceHostFactories.
I kept only the StructureMapRestServiceHostFactory : WebServiceHost2Factory and ServiceCategoryRest.svc which handles well requests in REST mode and call in RPC-SOAP mode.
So if you want to run side by side the REST and the SOAP you can do it only with WebServiceHost2Factory.
If then you want to get rid of the .svc part from the URL, please read the Rick Strahl post west-wind.com/weblog/posts/570695.aspx.

Is it bad to have 'You have created a service' page for published wcf service on the internet?

I have created wcf service and planning to make it accessible from the internet. The page 'You have created a service' seems to be some stub which should be replaced before putting service on production. Is it a bad practice to have this welcome page on production? What do you do with that welcome page when you publish wcf services on the internet?
Thanks
On production you can turn off this page by adding:
<behaviors>
<serviceBehaviors>
<behavior name="ProductionService">
<serviceDebug includeExceptionsInDetail="false" httpHelpPageEnabled="false" />
</behavior>
<serviceBehaviors>
</behavirs>
Also think about publishing WSDL / Metadata. If you don't want to publish WSDL but you want to use mex endpoint use following configuration:
<behaviors>
<serviceBehaviors>
<behavior name="ProductionService">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionsInDetail="false" httpHelpPageEnabled="false" />
</behavior>
<serviceBehaviors>
</behavirs>
Your services must use those behavior in their behaviorConfiguration attribute.
Yes, it's bad. It says potential attackers that the system is non-configured completely, so they would try to attack it. Also, it's not very professional.
Well, print something useful there or hide it:-)