简体   繁体   English

如何使用 C# 从 WSDL 文件中将请求结构提取为每个操作的 xml 字符串

[英]how to extract the request structure as xml string of each operation from WSDL file using C#

I have implemented a svc service serTest.svc which contains 3 operation:我已经实现了一个包含 3 个操作的 svc 服务 serTest.svc:

opePing(PingRequest PingRequest) opePing(PingRequest PingRequest)
opeTest(Test Test) opeTest(测试测试)
opeTest1(Test Test1) opeTest1(测试测试1)

From the serTest.svc service I have generated a WSDL file.我从 serTest.svc 服务生成了一个 WSDL 文件。

I have implemented a small console program where I use the C# ServiceDescription class to read some info from the WSDL file.我已经实现了一个小型控制台程序,我使用 C# ServiceDescription class 从 WSDL 文件中读取一些信息。

What I want now is a example of C# code of how to extract the request structure as xml string of each operation from the WSDL file like this eg for opePing:我现在想要的是 C# 代码的示例,该代码如何从 WSDL 文件中提取请求结构作为 xml 字符串,例如 opePing:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<opePing xmlns="http://test/webservices/">
<header>
<Aktoer xmlns="">
<Domaene>Test</Domaene>
<Bruger>Test</Bruger>
</Aktoer>
<InitSystem xmlns="">
<Noegle>7c4e35ca-4f60-4aee-a1a0-7763393dad07</Noegle>
<Proces>AliverTester</Proces>
<Applikation>1100</Applikation>
<Version>8.2.0.0</Version>
<Maskine>DEV</Maskine>
<Tidsstempel>2021-04-22T15:30:43.4875383+02:00</Tidsstempel>
<Kontekst>Test</Kontekst>
</InitSystem>
<Proces xmlns="">
<CPR>000000</CPR>
</Proces>
</header>
</opePing>
</soap:Body>
</soap:Envelope>

I another way like what SOAPUI are doing and showing the request xml structure.我以另一种方式,例如 SOAPUI 正在做什么并显示请求 xml 结构。

It seems that I can't do this using the ServiceDescription class in C#.似乎我无法使用 C# 中的 ServiceDescription class 来执行此操作。

Anyone can help me with that?任何人都可以帮助我吗?

Try this online tool: https://www.wsdl-analyzer.com .试试这个在线工具: https://www.wsdl-analyzer.com It appears to be free and does a lot more than just generate XML for requests and response from WSDL.它似乎是免费的,并且不仅仅为来自 WSDL 的请求和响应生成 XML。

There is also this: https://www.oxygenxml.com/xml_editor/wsdl_soap_analyzer.html , which can be downloaded, but not free.还有这个: https://www.oxygenxml.com/xml_editor/wsdl_soap_analyzer.html ,可以下载,但不是免费的。

And I hope this link may help you alot.我希望这个链接可以帮助你很多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM