我如何在android中调用带有请求信封的soap服务。我得到了 SockettimeoutException。端点:e1jas01.domain.cssus.com:8091/DV910/AddressBookManager?WSDL
//Soap Request...
<Envelope>
<Body>
<getAddressBookV2Element>
<Entity>
<EntityId>9</EntityId>
</Entity>
</getAddressBookV2Element>
</Body>
</Envelope>
//Android代码... //在我尝试过的方法下面。
public void callWebservice()
{
private final String NAMESPACE1 = "http://oracle.e1.bssv.JP010000/";
private final String URL1 = "https://e1jas01.domain.cssus.com:8091/DV910/AddressBookManager";
private final String SOAP_ACTION1 = "http://oracle.e1.bssv.JP010000//getAddressBookV2";
private final String METHOD_NAME1 = "getAddressBookV2";
SoapObject request = new SoapObject(NAMESPACE1, METHOD_NAME1);
PropertyInfo weightProp =new PropertyInfo();
weightProp.name = "arg0";
weightProp.setValue("9");
request.addProperty(weightProp);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
// create header
Element[] header = new Element[1];
header[0] = new Element().createElement("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd","Security");
header[0].setAttribute(null, "mustUnderstand","1");
Element usernametoken = new Element().createElement("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "UsernameToken");
usernametoken.setAttribute(null, "Id", "UsernameToken-1");
header[0].addChild(Node.ELEMENT,usernametoken);
Element username = new Element().createElement(null, "n0:Username");
username.addChild(Node.IGNORABLE_WHITESPACE,"Gowtham");
usernametoken.addChild(Node.ELEMENT,username);
Element pass = new Element().createElement(null,"n0:Password");
pass.setAttribute(null, "Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText");
pass.addChild(Node.TEXT, "Gowtham");
usernametoken.addChild(Node.ELEMENT, pass);
Element[] body = new Element[1];
body[0] = new Element().createElement("http://oracle.e1.bssv.JP010000/","getAddressBookV2Element");
Element EntityNode = new Element().createElement("http://oracle.e1.bssv.JP010000/", "Entity");
body[0].addChild(Node.ELEMENT,EntityNode);
Element EntityIdNode = new Element().createElement("http://oracle.e1.bssv.JP010000/", "EntityId");
EntityIdNode.addChild(Node.IGNORABLE_WHITESPACE,"9");
EntityNode.addChild(Node.ELEMENT,EntityIdNode);
// add header to envelope
envelope.headerOut = header;
envelope.bodyOut = body;
envelope.dotNet = false;
envelope.bodyOut = request;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try
{
androidHttpTransport.debug = true;
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
Log.i("myApp", response.toString());
}
catch (SoapFault e)
{
e.printStackTrace();
}
catch (Exception e)
{
e.printStackTrace();
Log.d("Exception Generated", ""+e.getMessage());
}
}
我还尝试在 Soap 主体中添加 Propertyinfo 而不是 Element,但我仍然收到异常。相同的信封在soapUI 工具中效果很好。可以单独请帮助解决这个问题。
谢谢,戈瑟姆。