如何使用c#中的soapweb服务并在请求中传递XML



我需要你的帮助来找到在c#中调用soapweb服务的最佳方法?

我知道在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功能的资源可以实现这一点。希望这对伴侣有帮助。

最新更新