开发者

WSDL file is missing for WCF WebService

开发者 https://www.devze.com 2022-12-23 19:10 出处:网络
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 ca

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 ad开发者_JAVA百科ded 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号