Клиент AXIS2 возвращает объект с нулями вместо свойств - PullRequest
1 голос
/ 05 мая 2011

У меня есть такая структура, которую мне нужно вернуть через приложение webService

public class StructureClass implements Serializable
{

    public StructureClass()
    {
        exampleFIO = new FIO();
    }
    public FIO exampleFIO;
    public String result;
}

public class FIO implements Serializable{

    public String FirstName;
    public String LastName;

}

Приложение WebService:

public class ReturnObject {
    public StructureClass retObject()
    {
        StructureClass structClassObject = new StructureClass();
        structClassObject.exampleFIO.FirstName = "A";
        structClassObject.exampleFIO.LastName = "G";
        structClassObject.result = "good";
        return structClassObject;
    }
}

Я создаю приложение webservice с помощью AXIS2 и Eclipse

WSDL - это:

*<wsdl:definitions targetNamespace="http://objectreturn.xxxxxx.com">
<wsdl:documentation>
        Please Type your service description here
    </wsdl:documentation>
−
<wsdl:types>
−
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://objectreturn.xxxxxx.com/xsd">
−
<xs:complexType name="StructureClass">
<xs:sequence/>
</xs:complexType>
</xs:schema>
−
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://objectreturn.xxxxxx.com">
<xs:import namespace="http://objectreturn.xxxxxx.com/xsd"/>
−
<xs:element name="retObjectResponse">
−
<xs:complexType>
−
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="ax22:StructureClass"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="retObjectRequest"/>
−
<wsdl:message name="retObjectResponse">
<wsdl:part name="parameters" element="ns:retObjectResponse"/>
</wsdl:message>
−
<wsdl:portType name="ReturnObjectPortType">
−
<wsdl:operation name="retObject">
<wsdl:input message="ns:retObjectRequest" wsaw:Action="urn:retObject"/>
<wsdl:output message="ns:retObjectResponse" wsaw:Action="urn:retObjectResponse"/>
</wsdl:operation>
</wsdl:portType>
−
<wsdl:binding name="ReturnObjectSoap11Binding" type="ns:ReturnObjectPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
−
<wsdl:operation name="retObject">
<soap:operation soapAction="urn:retObject" style="document"/>
−
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
−
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
−
<wsdl:binding name="ReturnObjectSoap12Binding" type="ns:ReturnObjectPortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
−
<wsdl:operation name="retObject">
<soap12:operation soapAction="urn:retObject" style="document"/>
−
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
−
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
−
<wsdl:binding name="ReturnObjectHttpBinding" type="ns:ReturnObjectPortType">
<http:binding verb="POST"/>
−
<wsdl:operation name="retObject">
<http:operation location="ReturnObject/retObject"/>
−
<wsdl:input>
<mime:content type="text/xml" part="retObject"/>
</wsdl:input>
−
<wsdl:output>
<mime:content type="text/xml" part="retObject"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
−
<wsdl:service name="ReturnObject">
−
<wsdl:port name="ReturnObjectHttpSoap11Endpoint" binding="ns:ReturnObjectSoap11Binding">
<soap:address location="http://localhost:8080/XXXXXX/services/ReturnObject.ReturnObjectHttpSoap11Endpoint/"/>
</wsdl:port>
−
<wsdl:port name="ReturnObjectHttpSoap12Endpoint" binding="ns:ReturnObjectSoap12Binding">
<soap12:address location="http://localhost:8080/XXXXXX/services/ReturnObject.ReturnObjectHttpSoap12Endpoint/"/>
</wsdl:port>
−
<wsdl:port name="ReturnObjectHttpEndpoint" binding="ns:ReturnObjectHttpBinding">
<http:address location="http://localhost:8080/XXXXXX/services/ReturnObject.ReturnObjectHttpEndpoint/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>*

Когда я пытался вызвать его с помощью моего Клиента

RPCServiceClient serviceClient = new RPCServiceClient();
            Options options = serviceClient.getOptions();

            EndpointReference targetEPR = new EndpointReference(
                    "http://localhost:8080/XXXXXX/services/ReturnObject");
            options.setTo(targetEPR);

            options.setAction("sendAttachment");

            QName opGetObject = new QName("http://objectreturn.xxxxxx.com", "retObject");
            Object[] opSetArgs = new Object[] { };
            Class[] returnTypes = new Class[] { StructureClass.class };

            Object[] returnArray = serviceClient.invokeBlocking(opGetObject,
                    opSetArgs, returnTypes);


        StructureClass xx = (StructureClass)returnArray[0];

        System.out.println(xx.result);

Я получил ноль для всех свойствкласса xx

Не могли бы вы помочь, в чем может быть проблема здесь.

Спасибо, Андрей

1 Ответ

0 голосов
/ 05 мая 2011

Проверьте Axis2 Apache Tutorial и выполните код в соответствии с руководством.

(например, удалите реализации Serializable из классов, если вам это не нужно, создайте методы получения и установкиметоды в классах)

...