簡體   English   中英

如何在asmx Web服務(wsdl)中操作端口類型?

[英]How to manipulate Port Type in asmx Web Service (wsdl)?

我有一個asmx Web服務。 在我的wsdl中,我猜測默認生成的端口類型和綁定名稱。 我想要的是改變那些名字。我怎么能這樣做? 它與配置文件有關還是只有c#代碼可以處理這個問題。 你有什么方法可以讓wsdl像下面這樣。 謝謝你的回復!

我的wsdl:

<wsdl:message name="sendDocumentSoap12In">
<wsdl:part name="document" element="tns:documentRequest"/>
</wsdl:message>
<wsdl:message name="sendDocumentSoap12Out">
<wsdl:part name="sendDocumentResult" element="tns:documentResponse"/>
</wsdl:message>

<wsdl:portType name="EFaturaSoap12">
<wsdl:operation name="sendDocument">
<wsdl:input message="tns:sendDocumentSoap12In"/>
<wsdl:output message="tns:sendDocumentSoap12Out"/>
</wsdl:operation>
</wsdl:portType>

<wsdl:binding name="EFaturaSoap12" type="tns:EFaturaSoap12">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="sendDocument">
<soap12:operation soapAction="sendDocument" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>

我希望wsdl:

<wsdl:message name="sendDocument">
<wsdl:part element="tns:documentRequest" name="document"></wsdl:part>
</wsdl:message>
<wsdl:message name="sendDocumentResponse">
<wsdl:part element="tns:documentResponse" name="sendDocumentReturn"></wsdl:part>
</wsdl:message>

<wsdl:portType name="EFaturaPortType">
<wsdl:operation name="sendDocument">
<wsdl:input message="tns:sendDocument" name="sendDocument"></wsdl:input>
<wsdl:output message="tns:sendDocumentResponse" name="sendDocumentResponse"></wsdl:output>
<wsdl:fault message="tns:EFaturaFaultMessage" name="EFaturaFaultMessage"></wsdl:fault>
</wsdl:operation>
</wsdl:portType>

<wsdl:binding name="EFaturaSoapBinding" type="tns:EFaturaPortType">
<soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="sendDocument">
<soap12:operation soapAction="sendDocument" style="document"/>
<wsdl:input name="sendDocument">
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output name="sendDocumentResponse">
<soap12:body use="literal"/>
</wsdl:output>
<wsdl:fault name="EFaturaFaultMessage">
<soap12:fault name="EFaturaFaultMessage" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>

你可以說,WSDL是你的配置文件。你可以手動更改它,但就像你上面所做的那樣。 您需要在wsdl中檢查所有引用以更改值。 如上所述,您還需要使用新編輯的綁定名稱編輯服務標簽。

任何語言的任何Web服務實現都可以讓您對這些名稱進行有限的控制。您可以控制這些名稱的限制。

就像在jax-ws(用於XML webservice的JAVA API)中一樣。 您可以根據方法或接口名稱定義操作名稱,端口類型取決於您的類名。 通常在生成wsdl輸入消息時:MethodNameRequest和輸出消息:生成MethodNameResponse。我希望C#也為您提供類似的實現。

通常在wsdl中,

•可以將portType元素與傳統編程語言中的函數庫(或模塊或類)進行比較。

•可以將操作元素與傳統編程語言中的方法進行比較。

•message元素定義操作或方法的數據元素(輸入/輸出)。

如果您想經常使用wsdl進行這些更改,您可以編寫一個DOM解析器來根據您的要求生成帶有更改的wsdl。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM