• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Calling webservice: works from standalone app but not from weblogic  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm calling a SOAP 1.1 webservice which use basic HTTP authentication. All works well in a standalone class, but if I put the same code into a web application, for example in an Action class, it doesn't work. I receive a 500 response code, and an empty body. Can you help me?
My code looks like this, using the Apache Commons libraries:

...
HttpClient client = new HttpClient();
client.getState().setCredentials(
new AuthScope("<webservice_server>", 80),
new UsernamePasswordCredentials("<username>", "<password>")
);
PostMethod post = new PostMethod("<webservice_url>");
post.setRequestHeader("SOAPAction", "<webservice_url>#<method>");
post.setRequestBody(new StringBufferInputStream(input)); //input previously defined
post.setDoAuthentication(true);
try {
int status = client.executeMethod( post );
String body = post.getResponseBodyAsString();
if(status == 200){
return body;
}else{
throw new Exception("status: " + status + " body: " + body);
}
} finally {
post.releaseConnection();
}

Thank you

Simone
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!