格式SOAP响应
问题描述:
我试图创建一个Web服务,以制作一个简单的SOAP响应ping请求:格式SOAP响应
<soap:Envelope>
<soap:Body>
<CustomRS attr="somevalue">
<Success/>
</CustomRS>
</soap:Body>
</soap:Envelope>
相反,我得到这个响应
<soap:Envelope>
<soap:Body>
<PingResponse>
<CustomRS attr="somevalue">
<Success/>
</CustomRS>
</PingResponse>
</soap:Body>
</soap:Envelope>
“平安”是我的WebMethod和CustomRS的名称是我的Serializable响应对象。我如何摆脱PingResponse元素,并将CustomRS作为根元素?
我实现
@WebService (name = '', serviceName = ''targetNamespace = '')
@Stateless (mappedName = '')
public class TestEjb implements Testnterface {
@SOAPBinding(style=Style.DOCUMENT, use=Use.LITERAL, parameterStyle=ParameterStyle.BARE)
@WebResult (name = "CustomRS", targetNamespace = "name space")
@WebMethod (operationName = "CustomRS")
public CustomRS_OutPut Ping(@WebParam (name = "header",Type type,
@WebParam (name = "parameters", Param param) throws Exception
{
}
答
public SoapObject soap(String METHOD_NAME, String SOAP_ACTION,
String NAMESPACE, String URL) throws IOException,
XmlPullParserException {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); // set up
// request
request.addProperty("iTruckId", "1");
request.addProperty("iLocationId", "1");// variable name, value. I got
// the variable name, from the
// wsdl file!
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11); // put all required data into a soap
// envelope
envelope.setOutputSoapObject(request); // prepare request
AndroidHttpTransport httpTransport = new AndroidHttpTransport(URL);
httpTransport.debug = true; // this is optional, use it if you don't
// want to use a packet sniffer to check
// what the sent
// message was (httpTransport.requestDump)
httpTransport.call(SOAP_ACTION, envelope); // send request
SoapObject result = (SoapObject) envelope.getResponse(); // get response
return result;
}
}