[英]How to consume a soap web-service in c# and pass XML in request?
我需要您的幫助,以找到在C#中調用Soap Web服務的最佳方法?
我知道在c#中使用Web服務參考功能是一個很好的選擇。
我嘗試使用它,但是沒有用?
這是我要發布的XML
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cus="http://temenos.com/CUSTDETS">
<soapenv:Header/>
<soapenv:Body>
<cus:EDBCUSTDETS>
<WebRequestCommon>
<!--Optional:-->
<company></company>
<password></password>
<userName></userName>
</WebRequestCommon>
<EDBCUSTDETSType>
<!--Zero or more repetitions:-->
<enquiryInputCollection>
<columnName></columnName>
<criteriaValue></criteriaValue>
<operand>EQ</operand>
</enquiryInputCollection>
</EDBCUSTDETSType>
</cus:EDBCUSTDETS>
</soapenv:Body>
</soapenv:Envelope>
在服務引用文件夾中添加了WSDL的引用后,我將其命名為ServiceReference1。
現在我可以在我的代碼中看到:
如何實現這個要求?
如何添加公司,密碼和用戶名以及enquiryInputCollection參數?
是否有最佳實踐來實現這一目標?
謝謝。
如果您已經成功地從WSDL生成了分類的代理,那么您應該很好。 我認為應該為您提供使用它們的Web服務文檔。
尋找service client classes
。
例如:
var client = new ServiceReference1Client();
client. ? //(should list Methods and you can find Types of Paramaters to build them.)
如果簽入web.config / app.config,並且看到<client>
和<endpoint />
,則在此處提供端點地址。 如果您需要發送客戶端證書,則可能要選擇或並設置安全性,例如:
<security mode="Transport">
<transport clientCredentialType="Certificate" />
</security>
WCF功能上有很多資源可以實現此目的。 希望這可以幫助伴侶。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.