带有“any xml”的 Apache CXF 的 WSDL 文件身体
背景:我正在开发通过 WS 管理协议进行通信的 Web 服务。原始 WSDL 来自此处 http://schemas.xmlsoap.org/ws/ 2005/06/management/wsman.wsdl 看起来像:
<xs:complexType name="SampleResourceType">
<xs:sequence>
<xs:element name="PropertyA" type="xs:string"/>
<xs:element name="PropertyB" type="xs:int"/>
</xs:sequence>
</xs:complexType>
<xs:element name="SampleResource" type="tns:SampleResourceType"/>
<wsdl:message name="PutMessage">
<wsdl:part name="Body" element="tns:SampleResource"/>
</wsdl:message>
这个 WSDL 与 Apache CXF 2.4.0 配合得很好。
我的目标: 将 SampleResource 定义替换为其他定义,以让操作处理任何资源(XML)。我想为 SOAP 输出如下所示的操作创建 WSDL 文件:
<soap:Envelope>
<soap:Body>
<SomeXmlDocument></SomeXmlDocument>
</soap:Body>
</soap:Envelope>
SomeXmlDocument 在这里意味着运行时定义的任何 XML 文档。 现在的问题是 CXF 总是使用 WSDL 中的预定义名称。 我将展示示例:
我正在使用以下命令: wsdl2java.bat -fe jaxws21 -d gen -exsh true -verbose file.wsdl
如果我使用 wsdl:
<xs:complexType name="CIMObjectType">
<xs:sequence>
<xs:any namespace="##other" minOccurs="0" processContents="lax"/>
</xs:sequence>
</xs:complexType>
<xs:element name="CIMObject" type="tns:CIMObjectType"/>
<wsdl:message name="GetResponseMessage">
<wsdl:part name="Body" element="tns:CIMObject"/>
</wsdl:message>
输出如下:
<soap:Body>
<ns8:CIMObject>
<XXX>
<DeviceID>XXX:YYY</DeviceID>
</XXX>
</ns8:CIMObject>
</soap:Body>
如果我use:
<xs:complexType name="CIMObjectType">
<xs:sequence>
<xs:any namespace="##other" minOccurs="0" processContents="lax"/>
</xs:sequence>
</xs:complexType>
<xs:element name="CIMObject" type="tns:CIMObjectType"/>
<wsdl:message name="GetResponseMessage">
<wsdl:part name="Body" type="tns:CIMObjectType"/>
</wsdl:message>
输出看起来像:
<soap:Body>
<Body>
<XXX>
<DeviceID>XXX:YYY</DeviceID>
</XXX>
</Body>
</soap:Body>
但我需要:
<soap:Body>
<XXX>
<DeviceID>XXX:YYY</DeviceID>
</XXX>
</soap:Body>
所以,问题是:如何修改 WSDL 以获得我需要的输出?非常感谢任何帮助
Background: I'm developing web-service which communicates over WS-Management protocol. The original WSDL from here http://schemas.xmlsoap.org/ws/2005/06/management/wsman.wsdl looks like:
<xs:complexType name="SampleResourceType">
<xs:sequence>
<xs:element name="PropertyA" type="xs:string"/>
<xs:element name="PropertyB" type="xs:int"/>
</xs:sequence>
</xs:complexType>
<xs:element name="SampleResource" type="tns:SampleResourceType"/>
<wsdl:message name="PutMessage">
<wsdl:part name="Body" element="tns:SampleResource"/>
</wsdl:message>
And this WSDL works well with Apache CXF 2.4.0.
My goal:
Replace SampleResource definition with other to let operation handle any resource(XML). I'd like to create WSDL file for operation which SOAP output will look like:
<soap:Envelope>
<soap:Body>
<SomeXmlDocument></SomeXmlDocument>
</soap:Body>
</soap:Envelope>
And SomeXmlDocument means here any XML document defined in runtime.
The problem now CXF always puts predefined name from WSDL.
I'll show on examples:
I'm using following command: wsdl2java.bat -fe jaxws21 -d gen -exsh true -verbose file.wsdl
If I use wsdl:
<xs:complexType name="CIMObjectType">
<xs:sequence>
<xs:any namespace="##other" minOccurs="0" processContents="lax"/>
</xs:sequence>
</xs:complexType>
<xs:element name="CIMObject" type="tns:CIMObjectType"/>
<wsdl:message name="GetResponseMessage">
<wsdl:part name="Body" element="tns:CIMObject"/>
</wsdl:message>
The output looks like:
<soap:Body>
<ns8:CIMObject>
<XXX>
<DeviceID>XXX:YYY</DeviceID>
</XXX>
</ns8:CIMObject>
</soap:Body>
If I use:
<xs:complexType name="CIMObjectType">
<xs:sequence>
<xs:any namespace="##other" minOccurs="0" processContents="lax"/>
</xs:sequence>
</xs:complexType>
<xs:element name="CIMObject" type="tns:CIMObjectType"/>
<wsdl:message name="GetResponseMessage">
<wsdl:part name="Body" type="tns:CIMObjectType"/>
</wsdl:message>
Output looks like:
<soap:Body>
<Body>
<XXX>
<DeviceID>XXX:YYY</DeviceID>
</XXX>
</Body>
</soap:Body>
But I need:
<soap:Body>
<XXX>
<DeviceID>XXX:YYY</DeviceID>
</XXX>
</soap:Body>
So, the question is: how to modify WSDL to have output I need? Any help is greatly appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论