JAX WS xsd:任何类型都是XMLSchema元素

时间:2012-01-22 17:12:39

标签: web-services xsd jax-ws any

处理xsd:任何类型都是XMLSchema元素JAX WS

<types>
<schema targetNamespace="http://www.iona.com/artix/wsdl"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<complexType name="unmappedType">
<sequence>
<xsd:any namespace="##other"
processContents="skip"/>
</sequence>
</complexType>
<element name="request" type="tns:requestType"/>
</schema>
</types>

xml作为STring存在如何将其作为文档对象,然后将其内容传输到SOAPElement实例

需要有关实施和客户代码的指导。

将XML字符串转换为元素。并在收到回复后再回读。

1 个答案:

答案 0 :(得分:2)

我看到有人对您的问题进行了低估...如果您不介意,我会首先指出您的问题似乎存在的问题:该代码段很可能来自WSDL,但架构相当无效。你应该做的第一件事就是做对。也许是这样的:

<?xml version="1.0" encoding="utf-8"?>
<!--W3C Schema generated by QTAssistant/W3C Schema Refactoring Module (http://www.paschidev.com)-->
<schema targetNamespace="http://www.iona.com/artix/wsdl" xmlns:tns="http://www.iona.com/artix/wsdl" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
    <complexType name="unmappedType">
        <sequence>
            <any namespace="##other" processContents="skip"/>
        </sequence>
    </complexType>
    <element name="request" type="tns:unmappedType"/>
</schema>

完成后,我建议制作一个看起来像你想要的XML;确保你验证。将它与您的问题一起发布......

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!-- Sample XML generated by QTAssistant (http://www.paschidev.com) -->
<request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://www.iona.com/artix/wsdl">
    <any_element xmlns="otherNS">anyType</any_element>
</request>

然后我会使用一个免费且易于使用的工具JAXB(我推荐NetBeans,它有一个简单的界面)。然后编写一个使用您的代码的小型Java控制台应用程序;调试,看看你解组XML时得到了什么。也许阅读一些文档,然后最终发布以寻求更具体问题的帮助。

xsd:any和JAXB有很好的文档记录:试试JAXB ...