In the end, my biggest problem was that the URL I was passing to HttpPost and ksoap2 with SAP didn't work for me at all.
private void testCallingService() { DefaultHttpClient httpclient = new DefaultHttpClient(); httpclient.getCredentialsProvider().setCredentials( new AuthScope("ip here", port here), new UsernamePasswordCredentials(username, password)); try { String buffer = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:urn='namespace'><soapenv:Header/><soapenv:Body><urn:methodname><USERNAME>test</USERNAME></urn:methodname></soapenv:Body></soapenv:Envelope>"; HttpPost httppost = new HttpPost(url); StringEntity se = new StringEntity(buffer, HTTP.UTF_8); se.setContentType("text/xml"); httppost.setHeader("Content-Type", "application/soap+xml;charset=UTF-8"); httppost.setEntity(se); CredentialsProvider credsProvider = new BasicCredentialsProvider(); credsProvider.setCredentials(new AuthScope("ip", port), new UsernamePasswordCredentials(username, password)); httpclient.setCredentialsProvider(credsProvider); BasicHttpResponse httpResponse = (BasicHttpResponse) httpclient .execute(httppost); if (httpResponse.getStatusLine() != null) { System.out.println("Http status: " + httpResponse.getStatusLine()); } RequestLine requestLine = httppost.getRequestLine(); String response = getResponseBody(httpResponse);
So, I created a SOAP envelope, I will try to stop doing this in the near future. Created an instance of CredentialsProvider and set my user / password information. The status from server 200, and I get the information that I need. One problem remains that the answer is apparently too large (and it won't stop here), so my answer is truncated. Working to solve it now. I really hope this helps someone.
source share