首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Axis2客户端缺少基元类型的xsi类型属性

问Axis2客户端缺少基元类型的xsi类型属性
EN

Stack Overflow用户
提问于 2012-10-29 23:32:45
回答 1查看 2.7K关注 0票数 1

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

当向旧的webservice发送请求时,我遇到了一个问题,新的axis2客户端创建的请求缺少xsi:type属性,这是旧的服务器所期望的,因此服务器返回任何无法解析非类型化元素的错误。

新的旧请求看起来像这样

代码语言:javascript
复制
<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>

而新的是

代码语言:javascript
复制
<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“参数缺少”xsd:xsi:type=“,我认为这是主要问题。

这里有更多的技术细节:

wsdl看起来像这样

代码语言:javascript
复制
<?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的了解非常有限。所有试图在网上找到任何相关信息的尝试都没有成功。

非常感谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-11-02 15:27:56

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

Axis2 doesn't support rpc/encoded,我猜它也不包含支持文档/编码所需的位。最好的办法是向此服务器添加一个支持文档/文字的新接口。否则,使用Axis作为客户端时可能会卡住。讨论如何从JAX-WS客户端调用rpc/编码的服务的Here is a page。您也许能够根据自己的需要进行调整。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13124712

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档