2008-10-03 196 views
12

我正在我們的一臺服務器上的Windows服務中託管WCF服務。在使用basicHttpBinding工作並在.NET中構建測試客戶端後(最終工作),我繼續嘗試使用SoapClient類從PHP訪問它。最終消費者將是一個PHP站點,所以我需要使它在PHP中可用。在Windows服務中託管的WCF服務(basicHttpBinding)的WSDL URL

當我必須在PHP代碼中的SoapClient類的構造函數中輸入WSDL url時,我很難過。 WSDL在哪裏?我所擁有的是:

http://172.27.7.123:8000/WordServicehttp://172.27.7.123:8000/WordService/mex

這些都不不要暴露WSDL。作爲WCF新手我可能會問一個愚蠢的事情(或者我可能有一個錯誤的假設)。請溫柔:d

不,http://172.27.7.123:8000/WordService?wsdl不顯示任何比http://172.27.7.123:8000/WordService :(

難道我不得不承載它在IIS中不同的AM我被迫使用一個普通的WebService

+0

不錯。感謝搜索,發現你的問題和答案 – 2010-11-25 15:15:25

回答

9

這可能幫助:

http://msdn.microsoft.com/en-us/library/ms734765.aspx

簡而言之,您需要配置服務端點和行爲。這裏是一個簡單的例子:

<system.serviceModel> 
    <services> 

    <service 
     <!-- Namespace.ServiceClass implementation --> 
     name="WcfService1.Service1" 

     <!-- User behaviour defined below --> 
     behaviorConfiguration="SimpleServiceBehaviour"> 

     <endpoint 
     address="" 
     binding="basicHttpBinding" 
     <!-- Namespace.Interface that defines our service contract --> 
     contract="WcfService1.IService1"/> 

    </service> 
    </services> 
    <behaviors> 
    <serviceBehaviors> 
     <behavior name="SimpleServiceBehaviour"> 

     <serviceMetadata 
      <!-- We allow HTTP GET --> 
      httpGetEnabled="true" 

      <!-- Conform to WS-Policy 1.5 when generating metadata --> 
      policyVersion="Policy15"/> 

     </behavior> 
    </serviceBehaviors> 
    </behaviors> 
</system.serviceModel> 

不要忘記刪除XML註釋,因爲它們無效,它們在哪裏。

+2

我很抱歉,但鏈接似乎被破壞 – 2008-10-04 10:51:21

1

請參閱?此鏈接:

Exposing a WCF Service With Multiple Bindings and Endpoints

 
Unlike previous ASMX services, the WSDL (web service definition language) for WCF 
services is not automatically generated. The previous image even tells us that 
"Metadata publishing for this service is currently disabled.". 
This is because we haven't configured our service to expose any meta data about it. 
To expose a WSDL for a service we need to configure our service to provide meta information. Note: 
The mexHttpBinding is also used to share meta information about a service. While 
the name isn't very "gump" it stands for Meta Data Exchange. 
+0

也謝謝你:) - 你指出的文件也顯示httpGetEnabled設置爲true。 – 2008-10-05 19:40:35

相關問題