Axis2客户端缺少基本类型的xsi类型属性

时间:2012-10-29 15:32:45

标签: web-services axis2 xsitype

我正在尝试将我的客户端从axis1.x更新到axis2-1.6.2,而服务器端保持不变。 Web服务由ZSI webservice平台在python上实现。 使用WSDL2Java工具和XMLBeans数据绑定使用旧的wsdl文件成功生成客户端。

在向旧的Web服务发送请求时遇到问题,新的axis2客户端创建了缺少xsi:type属性的请求,该属性是 旧服务器因此服务器返回Any无法解析无类型元素 错误。

新旧请求看起来像

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:getSearchResult xmlns:ns1="http://www.iphrase.com/2003/11/oneStep/" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<arg xsi:type="xsd:string">
test
</arg>
</ns1:getSearchResult>
</soapenv:Body>
</soapenv:Envelope>

而新的

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ones:getSearchResult xmlns:ones="http://www.iphrase.com/2003/11/oneStep/">
<arg>
test
</arg>
</ones:getSearchResult>
</soapenv:Body>
</soapenv:Envelope>

你可以看到“arg”param缺少xsi:type =“xsd:string”,我认为这是主要问题。

这里有更多技术细节:

wsdl看起来像

<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" 
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
  xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
  xmlns:types="http://www.iphrase.com/2003/11/oneStep/encodedTypes"
  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:tns="http://www.iphrase.com/2003/11/oneStep/"
  xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
  xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
  targetNamespace="http://www.iphrase.com/2003/11/oneStep/"
  xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
  <xsd:schema targetNamespace="http://www.iphrase.com/2003/11/oneStep/encodedTypes">
    <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
    <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />


<xsd:simpleType name="arg">
  <xsd:restriction base="xsd:string">
  </xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="out">
  <xsd:restriction base="xsd:string">
  </xsd:restriction>
</xsd:simpleType>

 </xsd:schema>
</types>
<message name="getSearchResultSoapIn">
  <part name="arg" type="types:arg"/>
</message>
<message name="getSearchResultSoapOut">
  <part name="searchResult" type="types:out"/>
</message>

<portType name="QueryServiceSoap">
  <operation name="getSearchResult">
    <input message="tns:getSearchResultSoapIn"/>
    <output message="tns:getSearchResultSoapOut"/>
  </operation>
</portType>
<binding name="QueryServiceSoap" type="tns:QueryServiceSoap">
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
  <operation name="getSearchResult">
    <soap:operation soapAction="http://www.iphrase.com/2003/11/oneStep/getSearchResult" style="rpc" />
    <input>
      <soap:body use="encoded" namespace="http://www.iphrase.com/2003/11/oneStep/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
    </input>
    <output>
      <soap:body use="encoded" namespace="http://www.iphrase.com/2003/11/oneStep/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
    </output>
  </operation>
</binding>


<service name="QueryService">
  <port name="QueryServiceSoap" binding="tns:QueryServiceSoap">
      <soap:address location="http://9.148.51.231:8777/service" />
  </port>
</service>
</definitions>

看起来像axis2由于某种原因省略了原始类型的xsi:type, 我也找不到xmlns:xsd =“http://www.w3.org/2001/XMLSchema”xmlns:xsi =“http://www.w3.org/2001/XMLSchema-instance 命名空间可能它也是相关的。 我假设使用Axis2客户端也不需要升级服务器。

有人可以给出方向,看起来像任何配置问题,但我对axis2的了解非常有限。 所有在网络上找到任何相关内容的尝试都没有成功。

非常感谢

1 个答案:

答案 0 :(得分:1)

在您的WSDL中,查看binding部分指定style="document"use="encoded"的位置?此WSDL指定了文档/编码样式,这是非标准且非常不寻常的。 This page描述了四种样式(RPC vs document,编码VS文字),你会看到作者不会在文档/编码上花费任何空间。

Axis2 doesn't support rpc/encoded,我的猜测是它不包含支持文档/编码所需的位数。最好的办法是为此服务器添加一个支持document / literal的新界面。否则,您可能会因为客户端使用Axis而陷入困境。 Here is a page讨论从JAX-WS客户端调用rpc / encoded服务。您可以根据自己的需要进行调整。

相关问题