通过 WSDL 生成的 WCF 代理类发送任意 XML
我有一个手写的 WSDL,以及一些 XSD 文件。 .NET 客户端需要从磁盘加载 XML 文档并将其内容作为 SOAP 消息的一部分发送。根据我所阅读的内容,我认为我需要影响 svcutil.exe 或 wsdl.exe 将 SOAP 消息的这一部分视为 XmlElement,而不是尝试为其创建类型。
将消息的一部分指定为架构中的
是正确的方法吗?
是否有另一种方法可以让我在不使用
的情况下正确指定架构中的消息?
我可以控制 WSDL 和 Java 服务实现,但对 WCF 客户端的控制较少。
下面是来自 WSDL 的示例消息:
<wsdl:message name="TransmitFoo">
<wsdl:part name="body" element="someprefix:TransmitFooRequest"/>
</wsdl:message>
<wsdl:portType...>
<wsdl:operation name="TransmitFoo">
<wsdl:input message="tns:TransmitFoo">
</wsdl:operation>
</wsdl:portType>
架构中 TransmitFooRequest
的定义如下:
<xs:element name="TransmitFooRequest">
<xs:complexType>
<xs:all>
<xs:element name="someValue" type="xs:string"/>
<xs:element ref="someprefix:bar" />
</xs:all>
</xs:complexType>
</xs:element>
在架构中定义。这是从磁盘加载的部分。我希望生成的 WCF 代理类具有如下所示的方法签名:
TransmitFoo(String someValue, XmlElement bar)
我已经看到了类似要求的答案,其中 WSDL 是从 WCF 服务器生成的;我正在做相反的事情,从 WSDL 生成 WCF 客户端存根。
我意识到客户端也可以完全手动构建 SOAP 消息和标头,如另一个答案中所示,但我想避免重新实现 SOAP。
I have a hand-written WSDL, along with a few XSD files. A .NET client needs to load an XML document from disk and send its contents as part of the SOAP message. From what I've been reading I think I need to influence svcutil.exe or wsdl.exe to treat this part of the SOAP message as an XmlElement, rather than trying to create types for it.
Is the correct way to do this to specify part of the message as an <xs:any>
in the schema?
Is there another way that would allow me to properly specify the message in the schema without using <xs:any>
?
I have control over the WSDL and the Java service implementation, and somewhat less control over the WCF client.
Here's a sample message from the WSDL:
<wsdl:message name="TransmitFoo">
<wsdl:part name="body" element="someprefix:TransmitFooRequest"/>
</wsdl:message>
<wsdl:portType...>
<wsdl:operation name="TransmitFoo">
<wsdl:input message="tns:TransmitFoo">
</wsdl:operation>
</wsdl:portType>
The definition of TransmitFooRequest
from the schema is as follows:
<xs:element name="TransmitFooRequest">
<xs:complexType>
<xs:all>
<xs:element name="someValue" type="xs:string"/>
<xs:element ref="someprefix:bar" />
</xs:all>
</xs:complexType>
</xs:element>
<someprefix:bar>
is defined in the schema. This is the part that is loaded from disk. I'd like the generated WCF proxy class to have a method signature kind of like this:
TransmitFoo(String someValue, XmlElement bar)
I have seen an answer for a similar requirement where the WSDL is generated from the WCF server; I am doing the opposite, generating WCF client stubs from a WSDL.
I realize the client could also build the SOAP message and headers completely manually, as in another answer, but re-implementing SOAP is something I'd like to avoid.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论