2012-03-30 54 views
0

我想使用WCFExtras從我的服務(ExternalOrderService.svc)獲取單個文件的WSDL。WCFExtras web.config指向(我的)外部服務

我從WCFExtras SampleServer項目中修改了原來的web.config,添加了對我的服務的引用。 ServerSample工作正常,我成功地調用了Sample.WsdlSample wsdl文件,但我沒有成功調用我的服務wsdl。 以下配置有什麼問題?

<system.serviceModel> 
    <services> 
     <service behaviorConfiguration="Sample.WsdlSampleBehavior" name="Sample.WsdlSample"> 
     <endpoint address="" behaviorConfiguration="Sample.WsdlSampleEndpointBehavior" binding="basicHttpBinding" contract="Sample.IWsdlSample"/> 
     </service> 
     <service behaviorConfiguration="Sample.SoapHeadersSampleBehavior" name="Sample.SoapHeadersSample"> 
     <endpoint address="" behaviorConfiguration="Sample.SoapHeadersSampleEndpointBehavior" binding="basicHttpBinding" contract="Sample.ISoapHeadersSample"/> 
     </service> 
     <service behaviorConfiguration="ExternalOrderServiceBehavior" name="ExternalOrderService"> 
     <endpoint address="" binding="basicHttpBinding" contract="Monclick.MVC2.Services.External.IExternalOrderService" /> 
     </service> 
    </services> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="Sample.WsdlSampleEndpointBehavior"> 
      <wsdlExtensions location="http://127.0.0.1/Sample/WsdlSample.svc" singleFile="True"/> 
     </behavior> 
     <behavior name="Sample.SoapHeadersSampleEndpointBehavior"> 
      <wsdlExtensions location="http://127.0.0.1/Sample/SoapHeadersSample.svc"/> 
     </behavior> 
     <behavior name="ExternalOrderServiceBehavior"> 
      <wsdlExtensions location="http://api.local/Services/ExternalOrderService.svc" singleFile="true" /> 
     </behavior> 
     </endpointBehaviors> 
     <serviceBehaviors> 
     <behavior name="Sample.WsdlSampleBehavior"> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true" httpHelpPageEnabled="false"/> 
     </behavior> 
     <behavior name="Sample.SoapHeadersSampleBehavior"> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
     </behavior> 
     <behavior name="ExternalOrderServiceBehavior"> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <extensions> 
     <behaviorExtensions> 
     <!-- Declare that we have an extension called WSDL Extras--> 
     <add name="wsdlExtensions" type="WCFExtras.Wsdl.WsdlExtensionsConfig, WCFExtras, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/> 
     </behaviorExtensions> 
    </extensions> 
    </system.serviceModel> 

回答

0

的問題是在這部分代碼:

<service behaviorConfiguration="ExternalOrderServiceBehavior" name="ExternalOrderService"> 
    <endpoint address="" binding="basicHttpBinding" contract="Monclick.MVC2.Services.External.IExternalOrderService" /> 
    </service> 

你還沒有爲您服務的終端定義的behaviorConfiguration。更改爲此,它應該工作:

<service behaviorConfiguration="ExternalOrderServiceBehavior" name="ExternalOrderService"> 
    <endpoint address="" behaviorConfiguration="ExternalOrderServiceBehavior" binding="basicHttpBinding" contract="Monclick.MVC2.Services.External.IExternalOrderService" /> 
    </service> 
0

不同之處在於地址。工作的服務有「127.0.0.1」不工作的服務有「api.local」。

嘗試用「127.0.0.1」替換「api.local」。

我看到的另一件事是,你沒有任何mex端點定義。

+0

是不是可以引用遠程服務?讓我們來說說api.local? – 2012-04-02 12:10:55

+0

是的,如果api.local是一個註冊的DNS名稱,但它看起來不像是一個DNS名稱,儘管它可能是。 – 2012-04-02 17:57:05