0

私はアンドロイドが初めてです。アプリケーションで SOAP Web サービスを呼び出そうとしましたが、意味がわかりません

for(SOAP_Action,OperationName,WSDL_TARGET_NAMESPACE,SOAP_ADDRESS)。以下は私の完全なコードです

public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);

TextView textView = new TextView(this);

setContentView(textView);

SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,
OPERATION_NAME);

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
System.out.println("subbu="+request);
envelope.setOutputSoapObject(request);

HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS); 
try 
{ 
httpTransport.call(SOAP_ACTION, envelope); 
Object response = envelope.getResponse();
textView.setText(response.toString()); 
} 
catch (Exception exception) 
{ 
textView.setText(exception.toString());
}
}
}

誰がその目的を説明できますか。アイデアを得ることができるリンクをいくつか提供してください。

4

1 に答える 1

0

SOAP_ACTION / NAMESPACE および METHODS は、対象の Web サービスの WSDL ファイルにあります。

以下は、SOAP リクエストを Web サービスに送信するサンプル コードです。

public class SoapRequest {
private static final String SOAP_ACTION = "xxx";
private static final String METHOD_NAME = "xxx";
private static final String NAMESPACE = "xxx";
private static final String URL = "url of the webservice";

public static SoapObject soap() throws IOException, XmlPullParserException {
    SoapObject request = new SoapObject (NAMESPACE, METHOD_NAME);

/* Here you can add properties to your requests */
    PropertyInfo pi1 = new PropertyInfo();
    pi1.name = "xxx";
    pi1.type = String.class;
    request.addProperty(pi1, "xxx");

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.setOutputSoapObject(request);
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
    androidHttpTransport.debug = true; 
    androidHttpTransport.call(SOAP_ACTION, envelope);
    SoapObject soapResult = (SoapObject) envelope.bodyIn;
    return soapResult;
}
于 2014-07-12T08:21:43.473 に答える