返回wsdl响应中的对象

时间:2016-10-24 14:42:18

标签: java web-services soap wsdl

这是that question

的一部分

我想整合一个系统和强大的系统输入/输出参数。该系统由wsdl运行。这就是我在ng serve上创建web-service的原因:

java

我的PerformTransactionResult类是:

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import java.util.Date;

@SOAPBinding(style=SOAPBinding.Style.DOCUMENT)
public class WebServices {  

    @WebMethod
    public PerformTransactionResult Test2(){
        PerformTransactionResult performTransactionResult = new PerformTransactionResult();
        performTransactionResult.setErrorMsg("test");
        return performTransactionResult;
    }
}

我正在整合的系统希望得到这样的响应:

import org.apache.cxf.aegis.type.java5.XmlType;    
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "PerformTransactionResult")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "PerformTransactionResult")
public class PerformTransactionResult {    

    private String errorMsg;

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }  

}

我的<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <uws:PerformTransactionResult xmlns:uws="http://uws.provider.com/"> <errorMsg>Ok</errorMsg> </uws:PerformTransactionResult> </s:Body> </s:Envelope> 正在收到回复:

web-service

如您所见,回复应该返回<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <ns1:Test2Response xmlns:ns1="http://wservices.myhost.lan/"> <return xmlns:ns2="http://wservices.myhost.lan/"> <errorMsg>test</errorMsg> </return> </ns1:Test2Response> </soap:Body> </soap:Envelope> ,而不是PerformTransactionResult。如何实现该任务?

0 个答案:

没有答案