簡體   English   中英

AXIS2客戶端返回帶空值而不是屬性的對象

[英]AXIS2 client returns object with nulls instead of properties

我有一個需要通過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;
    }
}

我在AXIS2和Eclipse的幫助下構建了Web服務應用程序

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的所有屬性,我都為

您能幫忙解決一下這里可能出現的問題嗎?

謝謝,安德魯

查看Axis2 Apache教程 ,並根據該教程執行代碼。

(例如,從類中刪除實現Serializable的實現,除非您確實需要,在類中創建getter和setter方法)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM