• 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:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!