c# - 如何在 C# 中使用肥皂网络服务并在请求中传递 XML?
问题描述
我需要你的帮助来找到在 c# 中调用肥皂网络服务的最佳方法吗?
我知道在 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,并且如果您看到 and<client>
和<endpoint />
,这就是您提供端点地址的地方。如果您需要发送客户端证书,您可能希望从 or 开始并设置安全性,例如:
<security mode="Transport">
<transport clientCredentialType="Certificate" />
</security>
有很多关于 WCF 功能的资源来实现这一点。希望这有助于交配。
推荐阅读
- python - 你需要什么拉链?
- javascript - 如何将多个scss文件捆绑到一个文件中
- elasticsearch - Kibana 通过索引限制访问
- python - 聚类数百万个大型二元向量?
- python - Python DataFrame:在同一行中查找重复项?
- wpf - 如何通过检查 CheckBox 获取 DataGrid 中的行 ID?
- javascript - 如何使用 p5.js 草图作为网站的加载器?
- javascript - 我正在尝试显示选择到 div 中的每个复选框的值
- c# - 使用 ?? 进行空值检查有什么好处?操作员?
- wordpress - PHP:Wordpress功能中的多项选择