如何从生成的存根中获取响应XML

时间:2014-05-28 18:04:21

标签: web-services soap wsdl axis2

我使用Axis2的wsdl2java为以下WSDL生成存根(请注意,如果名称不匹配,可能来自我对代码的混淆) :

<?xml version="1.0" encoding="UTF-8" standalone="no"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:sch="http://test.com/saucy/schemas" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://test.com/saucy/definitions" targetNamespace="http://test.com/saucy/definitions">
  <wsdl:types>
    <xs:schema xmlns:wtfd="http://test.com/saucy/schemas" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://test.com/saucy/schemas">
    <xs:element name="fubarmanagerRequest">
        <xs:complexType>
            <xs:sequence>
                <xs:element maxOccurs="1" name="addUsers" type="wtfd:addUsersType"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:complexType name="addUsersType">
        <xs:sequence>
            <xs:element maxOccurs="unbounded" name="user" type="wtfd:userType"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="userType">
        <xs:sequence>
            <xs:element maxOccurs="1" minOccurs="1" name="emailAddress" type="xs:string"/>
            <xs:element maxOccurs="1" minOccurs="1" name="password" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>
</xs:schema>
  </wsdl:types>
  <wsdl:message name="fubarmanagerRequest">
    <wsdl:part element="sch:fubarmanagerRequest" name="fubarmanagerRequest">
    </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="wtfsaucy">
    <wsdl:operation name="fubarmanager">
      <wsdl:input message="tns:fubarmanagerRequest" name="fubarmanagerRequest">
    </wsdl:input>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="wtfsaucySoap11" type="tns:wtfsaucy">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="fubarmanager">
      <soap:operation soapAction=""/>
      <wsdl:input name="fubarmanagerRequest">
        <soap:body use="literal"/>
      </wsdl:input>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="wtfsaucyService">
    <wsdl:port binding="tns:wtfsaucySoap11" name="wtfsaucySoap11">
      <soap:address location="http://localhost:8080/mailerManagerService/"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

但是,生成的存根似乎并没有为我提供检索响应XML的方法:

/**
  * Auto generated method signature
  * 
  */
public void  fubarManager(com.obfuscated.fubarRequest fubarRequest0

) throws java.rmi.RemoteException

我能够在SoapUI中获取响应XML,但是如何通过Web生成的服务客户端代码检索它?我的WSDL缺少什么?我应该传递给wsdl2java吗?

1 个答案:

答案 0 :(得分:0)

我必须确保我的WSDL包含响应消息的部分:

<wsdl:portType name="wtfDirect">
  <wsdl:operation name="MailManager">
    <wsdl:input message="tns:MailManagerRequest" name="MailManagerRequest">
    </wsdl:input>
    <wsdl:output message="tns:MailManagerResponse" name="MailManagerResponse">
    </wsdl:output>
  </wsdl:operation>
</wsdl:portType>