0

Working request using HttpURLConnection

public static String ExecuteSoapRequest(String requestBody) {
        try {
            String url = PragMServe.readShared("url");
            if (!url.endsWith("/"))
                url += "/";

        StringBuilder xml = new StringBuilder();
        xml.append("<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:a=\"http://www.w3.org/2005/08/addressing\">");
        xml.append(PragMServe.readShared("header"));
        xml.append(requestBody);
        xml.append("</s:Envelope>");

        URL SoapURL = new URL(url + "XRMServices/2011/Organization.svc");
        HttpURLConnection rc = (HttpURLConnection) SoapURL.openConnection();

        rc.setRequestMethod("POST");
        rc.setDoOutput(true);
        rc.setDoInput(true);
        rc.setRequestProperty("Content-Type",
                "application/soap+xml; charset=UTF-8");
        String reqStr = xml.toString();
        int len = reqStr.length();
        rc.setRequestProperty("Content-Length", Integer.toString(len));
        rc.setConnectTimeout(5000);
        rc.connect();
        OutputStreamWriter out = new OutputStreamWriter(rc.getOutputStream());
        out.write(reqStr, 0, len);
        out.flush();

        int statusCode = rc.getResponseCode();
        String response;
        if (statusCode >= 200 && statusCode < 400) {
            response = convertStreamToString(rc.getInputStream());
        } else {
            response = convertStreamToString(rc.getErrorStream());
        }
        rc.disconnect();

        return response;
    } catch (Exception e) {
        Log.e("TAG", e.getMessage(), e);
    }
    return null;
}

private static String convertStreamToString(java.io.InputStream is) {
    java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
    return s.hasNext() ? s.next() : "";
}

Retrofit Request

public interface ICRMSoapService {
    @Headers({
            "Content-Type: application/soap+xml; charset=utf-8",
    })
    @HTTP(method = "POST", hasBody = true)
    Call<ResponseBody> postData(@Url String url, @Body String body);

}

public ICRMSoapService soapService;

public void initRetrofit() { 

        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
        interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();

        Strategy strategy = new AnnotationStrategy();
        Serializer serializer = new Persister(strategy);
        Retrofit retrofit = new Retrofit.Builder()
                .client(client)
                .addConverterFactory(SimpleXmlConverterFactory.create(serializer))
                .baseUrl(PragMServe.readShared("url"))
                .build();
        soapService = retrofit.create(ICRMSoapService.class);
}

 //RequestBody requestBody =RequestBody.create(MediaType.parse("text/plain"), xml.toString());
            Call<ResponseBody> data = soapService.postData(url + "XRMServices/2011/Organization.svc", xml.toString());
            retrofit2.Response body = data.execute();

Gradel

compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile ('com.squareup.retrofit2:converter-simplexml:2.2.0') {
    exclude group: 'xpp3', module: 'xpp3'
    exclude group: 'stax', module: 'stax-api'
    exclude group: 'stax', module: 'stax'
}

Using HttpURLConnection i am able to retrieve data but using retrofit i am getting 400 bad request error.

ERROR

Response{protocol=http/1.1, code=400, message=Bad Request, url=XXX}

What i am doing wrong?

Update

04-27 11:29:04.870 8717-9245/com.pragm.pragmam_serve D/OkHttp: <string>&lt;s:Envelope xmlns:s=&quot;http://www.w3.org/2003/05/soap-envelope&quot; xmlns:a=&quot;http://www.w3.org/2005/08/addressing&quot;&gt;&lt;s:Header&gt;&lt;a:Action s:mustUnderstand=&quot;1&quot;&gt;http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute&lt;/a:Action&gt;&lt;Security xmlns=&quot;http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd&quot;&gt;&lt;EncryptedData Id=&quot;Assertion0&quot; Type=&quot;http://www.w3.org/2001/04/xmlenc#Element&quot; xmlns=&quot;http://www.w3.org/2001/04/xmlenc#&quot;&gt;&lt;EncryptionMethod Algorithm=&quot;http://www.w3.org/2001/04/xmlenc#tripledes-cbc&quot;/&gt;&lt;ds:KeyInfo xmlns:ds=&quot;http://www.w3.org/2000/09/xmldsig#&quot;&gt;&lt;EncryptedKey&gt;&lt;EncryptionMethod Algorithm=&quot;http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p&quot;/&gt;&lt;ds:KeyInfo Id=&quot;keyinfo&quot;&gt;&lt;wsse:SecurityTokenReference xmlns:wsse=&quot;http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd&quot;&gt;&lt;wsse:KeyIdentifier EncodingType=&quot;http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary&quot; ValueType=&quot;http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509SubjectKeyIdentifier&quot;&gt;BAhRlojQczWllwxXN8VPpk4Lj1Q=&lt;/wsse:KeyIdentifier&gt;&lt;/wsse:SecurityTokenReference&gt;&lt;/ds:KeyInfo&gt;&lt;CipherData&gt;&lt;CipherValue&gt;So1WH2fSmgUB9jwhdBVp0jAezdNlqhgw9NTS19BLXCevBG38oqyFBFMExc6qRxVJo0rLOXLHp7tg8SrYOm6KJf98CUp/Gajzu8nCL06hi+QPyrJ5eXrUgy4iZ9HYmfnHWZ6xey+29Duzef1FDVzrFtF/844ZGdyYyymGQK6I7ZKGJ3D6b2pd4qWRn3UbxiS6cyRiuZtecqzbfqQhIZyWYM1TYzDPSjoM8PFpCPVyIDEVCyRbC8K9lwZ4WHqF+kaZQgGLswOyw6ieoJ7ALlM8/UromAag6A+H7IdXHQ8q1zvw1XWE6BxSYJ7j4R851GFeiifl9Ebxgv1coOk7Bvpsuw==&lt;/CipherValue&gt;&lt;/CipherData&gt;&lt;/EncryptedKey&gt;&lt;/ds:KeyInfo&gt;&lt;CipherData&gt;&lt;CipherValue&gt;5R8w7Fcx5l4kQIkIcuUbqLVxG0gY6DcSnhYGWNZ6Zus7A3GTq//UIA7OZp+G8XD+gOhlkQ9Yic2ELCoFY1Y2k9/mtCG0RVUglR8RM7nIiZOmvZFogV8a/NJLnW4blUNap4UYalxlnBFByMnHO3v1FGcPJ8pqZE6LSb1KyJxmFDcQZD4tndCh5YsbCDbA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M7eY2/MseRMV9TvW+FYiz+hJG9xvQjhtUWr0x3lqiCemxnD++o5cdNH4Clfvg5ybz8649VtNxULahGv+TigHdhkEDjd9wObN4NHlMPx/Q28iQth+2y6HSFAXHhgLyfTBbccvOidyVlSNNuhNxRbwCQP4LeGkB6+tPf66rrTUE6Fvhxh9bmuoJhs+yNzxmxNR79p50i69i08Ie1giZzBtSpQQe1HNk8IaHZUUjwBjoB13MzyF60r0VFSu9UHWd4TIAqNV71Oimq6o+LhKwxg7R6UBssa/MTG6FMldfJFaxz303K+9lzeLiDZx/C9ND8mYwAbnwFTprhFZLDQVmoROoqeMdbNRO8rMUY+dA1A3P20tFaIYK+u3bEywIhFFKHDU0wBb8z2BMVB/vZWqZLHLdsCsPP0q21dfkQSpBw=&lt;/CipherValue&gt;&lt;/CipherData&gt;&lt;/EncryptedData&gt;&lt;/Security&gt;&lt;a:MessageID&gt;urn:uuid:e37eef33-64da-4b9a-b04e-e3adef2dbb82&lt;/a:MessageID&gt;&lt;a:ReplyTo&gt;&lt;a:Address&gt;http://www.w3.org/2005/08/addressing/anonymous&lt;/a:Address&gt;&lt;/a:ReplyTo&gt;&lt;a:To s:mustUnderstand=&quot;1&quot;&gt;https://pragmserve5.crm8.dynamics.com/XRMServices/2011/Organization.svc&lt;/a:To&gt;&lt;/s:Header&gt;  &lt;s:Body&gt;    &lt;Execute xmlns=&quot;http://schemas.microsoft.com/xrm/2011/Contracts/Services&quot; xmlns:i=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;      &lt;request i:type=&quot;b:WhoAmIRequest&quot; xmlns:a=&quot;http://schemas.microsoft.com/xrm/2011/Contracts&quot; xmlns:b=&quot;http://schemas.microsoft.com/crm/2011/Contracts&quot;&gt;        &lt;a:Parameters xmlns:c=&quot;http://schemas.datacontract.org/2004/07/System.Collections.Generic&quot; /&gt;        &lt;a:RequestId i:nil=&quot;true&quot; /&gt;        &lt;a:RequestName&gt;WhoAmI&lt;/a:RequestName&gt;      &lt;/request&gt;    &lt;/Execute&gt;  &lt;/s:Body&gt;&lt;/s:Envelope&gt;</string>
04-27 11:29:04.878 8717-9245/com.pragm.pragmam_serve D/OkHttp: --> END POST (10011-byte body)

Xml string is not printing in xml format. i am creating dynamic soap envelope so i may not able to create model class for envelope, I referred this but he is creating soap envelope using modal class i want to pass raw string xml, is there any way to pass raw xml string to retrofit body.

Community
  • 1
  • 1
Prasanth S
  • 3,725
  • 9
  • 43
  • 75

1 Answers1

0

Your code looks pretty good. But there are few things that I want to mention. First of all make sure the web-service method you are trying to access is "POST" method and not "GET" or some other method type. Secondly make sure the XML/JSON you want to send to server is in proper format. Third I can see an issue in your code line given below is rc.setRequestProperty("Content-Type", "application/soap+xml; charset=UTF-8"); There should be a comma after "xml" and not semi-colon I guess.

After checking all these things if you still face the issue, then I'll suggest you to use "Log Level on Retrofit" to track the actual issue. Please check the link given below to implement "Log Level on Retrofit".

Logging with Retrofit 2

Community
  • 1
  • 1
Zohaib Hassan
  • 984
  • 2
  • 7
  • 11
  • now i found my issue, that bcoz of xml format was wrong issue my xml prints like this <SOAP-ENV:Envelope MY_OBJECTS SOAP-ENV:Envelope> how to pass dynamic xml – Prasanth S Apr 25 '17 at 04:28
  • Please have a look on the answer in the link given below. In this answer the user is using an XML parser of Retrofit to pass XML value. Hope this will work in your situation. http://stackoverflow.com/questions/37825990/post-soap-xml-request-with-retrofit – Zohaib Hassan Apr 25 '17 at 21:59
  • i tried that but my xml is dynamic so i cant create model class for envelope – Prasanth S Apr 26 '17 at 04:10