如何在没有 WSDL 的情况下创建 SOAP 客户端
我需要访问安全的网络服务, header中的每个请求都需要携带一个token。
我知道网络服务的端点, 我也知道如何创建令牌。
但我看不到 Web 服务的 WSDL。
C# 有没有办法在没有 WSDL 文件的情况下创建肥皂客户端。
i need to visit a secure web service,
every request in the header need to carry a token.
i know the endpoint to the web service,
i also know how to create the token.
but i cannot see the WSDL for the webservice.
is there a way in C#, to create a soap client, without the WSDL file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我已经验证此代码使用 HttpWebRequest 类,有效:
您需要创建正确的 SOAP 信封并将其作为“xml”变量传递。这需要一些阅读。我发现这个 SOAP 教程很有帮助。
I have verified that this code, which uses the HttpWebRequest class, works:
You will need to create the proper SOAP envelope and pass that in as the "xml" variable. It takes some reading. I found this SOAP Tutorial to be helpful.
SOAP 客户端只是一个包含更多内容的 HTTP 客户端。请参阅 HttpWebRequest 类。然后,您必须创建自己的 SOAP 消息,可能使用 XML 序列化。
A SOAP client is simply an HTTP client with more stuff in it. See the HttpWebRequest class. You'll then have to create your own SOAP message, perhaps using XML Serialization.
您可以创建自己的服务,将其公开为具有 WSDL,然后从中生成客户端......有点漫长。
You could create your own service, expose it to have a WSDL and then generate the client from that... kind of the long way.
您能否要求 Web 服务的开发人员通过电子邮件向您发送 WSDL 和 XSD 文件?如果是这样,您可以将文件转储到文件夹中,然后使用硬盘上的 WSDL 添加服务引用。
Can you ask the developers of the web service to send you the WSDL and XSD file(s) by email? If so, you can dump the files in a folder and then add a Service Reference using the WSDL on your hard disk.