2016-02-25 27 views
3

我將WCF WS作爲控制檯應用程序運行,並且在使用網絡瀏覽器提取wsdl時缺少操作信息http://localhost:7903/MyService/?wsdl爲什麼使用?wsdl後綴獲取URL會產生沒有操作信息的wsdl?

爲什麼會這樣?無論如何,下面提到的wsdl有用嗎?

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://tempuri.org/"xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:i0="http://www.mycompany.com/nis/MyService/wsdl/v1.0"xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing"xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" name="ptMyService" targetNamespace="http://tempuri.org/"> 
<wsdl:import namespace="http://www.mycompany.com/nis/MyService/wsdl/v1.0" location="http://0.0.0.0:7903/MyService/?wsdl=wsdl0"/> 
<wsdl:types/> 
<wsdl:binding name="BasicHttpBinding_IptMyService" type="i0:IptMyService"> 
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/> 
</wsdl:binding> 
<wsdl:service name="ptMyService"> 
<wsdl:port name="BasicHttpBinding_IptMyService" binding="tns:BasicHttpBinding_IptMyService"> 
<soap:address location="http://0.0.0.0:7903/MyService/"/> 
</wsdl:port> 
</wsdl:service> 
</wsdl:definitions> 

實際WSDL看起來是這樣的:

<?xml version="1.0" encoding="UTF-8"?> 
<definitions 
    xmlns:cmp="http://www.mycompany.com/nis/MyService/v1.0" 
    xmlns:msgs="http://www.mycompany.com/nis/MyServicemessages/v1.0" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:tns="http://www.mycompany.com/nis/MyService/wsdl/v1.0" 
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
    targetNamespace="http://www.mycompany.com/nis/MyService/wsdl/v1.0" 
    name="MyServiceService" 
    xmlns="http://schemas.xmlsoap.org/wsdl/"> 

    <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" /> 
    <types> 
    <xsd:schema> 
     <xsd:import schemaLocation="mycompany.nis.MyServicemessages.xsd" namespace="http://www.mycompany.com/nis/MyServicemessages/v1.0" /> 
     <xsd:import schemaLocation="mycompany.nis.MyService.xsd" namespace="http://www.mycompany.com/nis/MyService/v1.0" /> 
    </xsd:schema> 
    </types> 


    <message name="mMyService"> 
    <part name="parameters" element="msgs:components" /> 
    </message> 
    <message name="mMyServiceResponse"> 
    <part name="parameters" element="msgs:syncresult" /> 
    </message> 
    <message name="GetComponentRequest"> 
    <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" /> 
    <part name="parameters" element="msgs:GetComponent" /> 
    </message> 
    <message name="GetComponentResponse"> 
    <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" /> 
    <part name="parameters" element="msgs:GetComponentResponse" /> 
    </message> 
    <message name="RequestHeaderMessage"> 
    <part name="RequestHeaderPart" element="msgs:RequestHeader" /> 
    </message> 
    <message name="ResponseHeaderMessage"> 
    <part name="ResponseHeaderPart" element="msgs:ResponseHeader" /> 
    </message> 

    <portType name="ptMyService"> 
    <operation name="MyService"> 
     <input message="tns:mMyService" /> 
     <output message="tns:mMyServiceResponse" /> 
    </operation> 
    <operation name="GetComponent"> 
     <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" /> 
     <input message="tns:GetComponentRequest" /> 
     <output message="tns:GetComponentResponse" /> 
    </operation> 
    </portType> 

    <binding name="bMyService" type="tns:ptMyService"> 
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> 
    <operation name="MyService"> 
     <soap:operation soapAction="MyServiceAction" /> 
     <input> 
     <soap:body use="literal" /> 
     <soap:header message="tns:RequestHeaderMessage" part="RequestHeaderPart" use="literal" /> 
     </input> 
     <output> 
     <soap:body use="literal" /> 
     <soap:header message="tns:ResponseHeaderMessage" part="ResponseHeaderPart" use="literal" /> 
     </output> 
    </operation> 
    <operation name="GetComponent"> 
     <soap:operation soapAction="GetComponent" /> 
     <input> 
     <soap:body use="literal" /> 
     <soap:header message="tns:RequestHeaderMessage" part="RequestHeaderPart" use="literal" /> 
     </input> 
     <output> 
     <soap:body use="literal" /> 
     <soap:header message="tns:ResponseHeaderMessage" part="ResponseHeaderPart" use="literal" /> 
     </output> 
    </operation> 
    </binding> 

    <service name="MyServiceService"> 
    <port name="MyServicePort" binding="tns:bMyService"> 
     <soap:address location="http://localhost:7903/MyService" /> 
    </port> 
    </service> 
</definitions> 
+1

這是問題嗎? http://stackoverflow.com/q/4214815 – approxiblue

+0

謝謝!可能。我試試這個,讓你知道。如果是這樣,寫下答案並獲得獎勵。 –

+0

是的。有用。你可以寫答案,我會接受+100賞金。 –

回答

0

確保您的手術方法做ReplyAction設置爲 「*」,因爲WsdlExporter,生成WSDL元數據,忽略了這樣的方法。

[OperationContract(ReplyAction="*")] 
string SampleMethod(string msg); 

根據MSDN

指定的服務星號指示WCF不答覆操作添加到該消息,如果你是直接針對編程的消息這是有用的。