誰かがksoap2ヘッダーを手伝ってくれるかどうか疑問に思いました。これは私のsoapUIリクエストであり、ksoap2でサービスを使用するために変換する必要があります。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tim="http://www.xxx.co.uk/schemas/111.Security">
<soapenv:Header>
<ip>127.0.0.1</ip>
</soapenv:Header>
<soapenv:Body>
<tim:Login>
<tim:userName>username</tim:userName>
<tim:password>pass</tim:password>
</tim:Login>
</soapenv:Body>
</soapenv:Envelope>
そして、これは私が日食する私のクラスです:
private static final String SOAP_ACTION="http://www.xxx.co.uk/schemas/111.Security/ISecurity/Login" ;
private static final String METHOD_NAME="Login";
private static final String NAMESPACE="http://www.xxx.co.uk/schemas/111.Security";
private static final String URL="http://192.168.5.68:55969/Timesheet/yyy.111.Services/Security.svc";
そしてbuttonclicklistenerに私の行動があります:
@Override
public void onClick(View v)
{
try
{
SoapObject soap = new SoapObject(NAMESPACE, METHOD_NAME);
soap.addProperty("userName" ,txtUserName.getText().toString());
soap.addProperty("password",txtPassword.getText().toString());
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
Element[] headers = new Element[1];
Element element = new Element();
element.setName("ip");
element.setNamespace(NAMESPACE);
element.addChild(Element.TEXT, "127.0.0.1");
headers[0] = element;
envelope.setOutputSoapObject(soap);
envelope.headerOut = headers;
envelope.bodyOut = soap;
HttpTransportSE transport = new HttpTransportSE(URL);
transport.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
String resultValue = response.toString();
lblStatus.setText(resultValue);
}
catch (Exception e)
{
new AlertDialog.Builder(this).setTitle("Error").setMessage("Error").show();
}
}
私の間違いはどこにありますか?