Skip to content

Instantly share code, notes, and snippets.

@jihao
Created February 7, 2012 06:38
Show Gist options
  • Save jihao/1757709 to your computer and use it in GitHub Desktop.
Save jihao/1757709 to your computer and use it in GitHub Desktop.
post soap request using apache-common-httpclient
private void postSOAPXML(String soapBody)
{
try {
// Get target URL
HttpClient httpclient = new DefaultHttpClient();
StringEntity strEntity = new StringEntity(soapBody, "text/xml", "UTF-8");
HttpPost post = new HttpPost(CAI3G_URL);
post.setHeader("SOAPAction","CAI3G#Create");
post.setEntity(strEntity);
// Execute request
HttpResponse response = httpclient.execute(post);
HttpEntity respEntity = response.getEntity();
if (respEntity != null) {
logger.info("Response:");
logger.info(EntityUtils.toString(respEntity));
} else {
logger.error("No Response");
}
}
catch (Exception e) {
logger.error("Other exception = " + e.toString());
}
}
@buddhaWorking
Copy link

Is it operation name or url is required in post.setHeader("SOAPAction","CAI3G#Create");
I mean SOAPAction value is URL or operation name

@jihao
Copy link
Author

jihao commented Sep 23, 2020

operation name, should be able to find in your schema file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment