2012-10-29 51 views
1

我試圖將我的客戶端從axis1.x更新到axis2-1.6.2,同時保持服務器端不變。 Web服務是通過ZSI webservice平臺在python上實現的。 使用WSDL2Java工具和XMLBeans數據綁定,客戶端使用舊的wsdl文件成功生成。Axis2客戶端丟失原始類型的xsi類型屬性

雖然發送請求到老web服務我遇到一個問題,新的Axis2客戶端創建缺失XSI請求:這是由 舊服務器,因此服務器返回的任何無法解析類型化元素 錯誤預期類型屬性。

新老請求看起來像

<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」 參數缺少的xsi:type = 「XSD:字符串」我認爲這是主要問題。

這裏更多的技術細節:

的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:類型爲基本類型, 我也沒有找到的xmlns:XSD =」 http://www.w3.org/2001/XMLSchema"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance 命名空間可能也是相關的 我假設使用Axis2客戶端doesn還需要升級服務器。

有人可以給出方向,看起來像任何配置問題,但我對axis2的瞭解非常有限。 所有試圖找到與網絡相關的東西都沒有成功。

非常感謝

回答

1

在你的WSDL,看到那裏的binding部分指定style="document"use="encoded"?這個WSDL指定了文檔/編碼風格,這是非標準的和非常不尋常的。 This page描述了四種樣式(RPC與文檔,編碼VS文字),你會發現作者沒有在文檔/編碼上花費任何空間。

Axis2 doesn't support rpc/encoded,我的猜測是它不包含支持文檔/編碼所需的位。你最好的選擇是給這個支持文檔/文字的服務器添加一個新的界面。否則,您可能會被客戶端的Axis卡住。 Here is a page討論從JAX-WS客戶端調用rpc/encoded服務。您可能能夠根據您的需求進行調整。

+0

非常感謝您的指導和有用的東西,事實上,沒有改變服務器端我沒有機會做一個過程是非常有幫助的。 –