1

Generally, I used the Soap web service. Now I want to use rest web services. I tried but I am unable to understand it. Here I provided the soap web service for the login.

How can I write it for Rest?

It means can anyone provide the sample rest service. Is it clear? If you need more info please let me know.

Code :

public String AuthenticateUser() throws SoapFault   
{    

    String data = "";
    String serviceUrl = DH_Constant.RB_Webservice_URL;
    String serviceNamespace = DH_Constant.RB_Webservice_Namespace; 
    String soapAction = "https://www.dicomhub.com/AuthenticateUser";
    String type_of_soap = "AuthenticateUser";      

    try
    {
        SoapObject Request = new SoapObject(serviceNamespace, type_of_soap);
        Request.addProperty("strUserName", DH_Constant.strLoginUserName);   
        Request.addProperty("strPassword", strPassword);            
        System.out.println("AuthenticateUser Request:"+Request.toString());
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;
        envelope.setOutputSoapObject(Request);

        try
        {
            HttpTransportSE androidHttpTransport = new HttpTransportSE(serviceUrl);
            androidHttpTransport.call(soapAction, envelope);
        }
        catch(Exception e)
        {
            System.out.println("Webservice calling error ->"+e.toString());
        }

        SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
        data = response.toString();
        System.out.println("AuthenticateUser:"+response.toString());    
    }
    catch(Exception e)
    {
        System.out.println("Soap Method Error ->"+e.toString());    
    }

    return data;
} 
4

0 回答 0