Skip to content Skip to sidebar Skip to footer

How To Get Namespace, Soap_action, Url And Method_name To Call Soap Request In Android

I have a url for calling in code I should call it with Ksoap2 library in code. My code is in below, final String NAMESPACE =''; final String URL =''; final String METHOD_NAME = '';

Solution 1:

Try this,

privatestaticfinalStringNAMESPACE="http://zarinpal.com/";
privatestaticfinalStringWSDL="https://www.zarinpal.com/pg/services/WebGate/service";
privatestaticfinalStringMETHOD_NAME="PaymentRequest";
privatestaticfinalStringSOAP_ACTION= WSDL + "#" + METHOD_NAME;

privatestaticStringTAG="soap";

publicstatic String callWebservice() {
    StringresponseDump="";
    try {
        SoapSerializationEnvelopeenvelope=newSoapSerializationEnvelope(SoapEnvelope.VER11);

        SoapObjectrequest=newSoapObject(NAMESPACE, METHOD_NAME);
        request.addProperty(HoldPayment.Amount, "1000");
        request.addProperty(HoldPayment.CallbackURL,"http://www.yoursoteaddress.ir/verify.php");
        request.addProperty(HoldPayment.Description,"pule kharide tala");
        request.addProperty(HoldPayment.Email,"za@gmail.com");
        request.addProperty(HoldPayment.MerchantID,"e579752a-a591-11e6-9304-000c295eb8fc");
        request.addProperty(HoldPayment.Mobile,"090123456789");

        envelope.bodyOut = request;
        HttpTransportSEtransport=newHttpTransportSE(WSDL);

        transport.debug = true;
        try {
            transport.call(SOAP_ACTION, envelope);
            StringrequestDump= transport.requestDump;
            responseDump = transport.responseDump;
            Log.e(TAG, requestDump);
            Log.e(TAG, responseDump);
        } catch (IOException e) {
            e.printStackTrace();
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
    return responseDump;
}

This is how I found NAMESPACE, WSDL, METHOD_NAME and SOAP_ACTION.

  1. NAMESPACE : Search for "targetNamespace" in the WSDL.
  2. WSDL/URL : Search for "soap:address" in the WSDL. The value in location is the URL.
  3. METHOD_NAME : I look at the arguments you were using to create the request. It had Amount, CallbackURL, Description, Email, MerchantID and Mobile (no AdditionalData). So I figured you are trying to call PaymentRequest method.
  4. SOAP_ACTION : Search for "soapAction" in the WSDL. Among the matches, look for the one related to PaymentRequest. The SOAP_ACTION is usually the URL + some_seperator + METHOD_NAME. The separator in this case was #.

And so I found everything that was required to make the request. Hope it helped you. Good luck.

Post a Comment for "How To Get Namespace, Soap_action, Url And Method_name To Call Soap Request In Android"