File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Web Services using soap

 
Mohammed Javeed Basha
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Client side web service having inputs and outputs like this, how to do invoke webservice from client side

Input:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:loc="http://www.elite.com/sdp/spb/local">
<soapenv:Header/>
<loc:Authentication>
<Username>string1</Username>
<Password>string2</Password>
</loc:Authentication>
</soapenv:Header>
<soapenv:Body>
<loc: getCircleInfo>
<loc:msisdn>+918802561213</loc:msisdn>
</loc: getCircleInfo>
</soapenv:Body>
</soapenv:Envelope>

Output:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getCircleInfoResponse xmlns:ns2="http://www.elite.com/sdp/spb/local">
<ns2:CircleInformation>
<MSISDN>+918802561213</MSISDN>
<SubscriberType>Prepaid</SubscriberType>
<CircleID>4</CircleID>
<CircleName>DLHI</CircleName>
<Zone>null</Zone>
</ns2:CircleInformation>
</ns2:getCircleInfoResponse>
</S:Body>
</S:Envelope>
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All the major SOAP implementations come with tools that create client-side Java code from the WSDL of the target WS. Check the documentation of whichever implementation you're using.
 
Mohammed Javeed Basha
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya i have done with jax-ws, ofcourse it generated some 6 files related to the client web service. But how and where to parse soapenvelope xml request and response, can you please provide me any example which parse the soapenvelope xml, or suggest any site for this particular example.
I'm having HeadHandler class, inside this class handleMessage(SOAPMessageContext smc) was like this
public boolean handleMessage(SOAPMessageContext smc) {

log.info("HeaderHandler::handleMessage Entering");
boolean isSuccess = true;
SOAPMessage message = null;
Boolean outBoundProperty = (Boolean)smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if(outBoundProperty.booleanValue()){
message = smc.getMessage();
}


try {
SOAPEnvelope envelope = smc.getMessage().getSOAPPart().getEnvelope();

System.out.println("smc-->"+smc+"-->"+smc.getMessage()+"soapPart"+smc.getMessage().getSOAPPart());
System.out.println("smc.getMessage().getSOAPPart().getEnvelope()--->"+smc.getMessage().getSOAPPart().getEnvelope());
envelope.addNamespaceDeclaration("loc","http://www.wipro.com/sdp/spb/local");
SOAPHeader header = null;
System.out.println("envelope-->"+envelope);
if(envelope.getHeader()!= null)
header = envelope.getHeader();
else
header = envelope.addHeader();
SOAPHeaderElement loc = (SOAPHeaderElement) header.addChildElement("loc", "Authentication");
log.info("HeaderHandler::handleMessage::ENVIRONMENT: "+getProp().getPropertyValue(FlyppISConstants.ENVIRONMENT));


SOAPElement username = loc.addChildElement("Username");
username.addTextNode(strUsername);

SOAPElement password = loc.addChildElement("Password");
password.addTextNode(strPassword);


} catch (Exception e) {
e.printStackTrace();
}

return isSuccess;
}

Here envelope itself getting null value and it leads to error, unable to get header.

Can you please suggest any
 
Praful Thakare
Ranch Hand
Posts: 642
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well, with the quality of question I am assuming you are way far away from deploying and executing a webserivce of this complexity.

I would suggest you learn it step by step, understand the basics of WS and its different components + architecture. Getting a book is best option but there are tons of resources on web, just Google.

In my opinion even if you resolve this issues, it will not help much to understand whats going on.

Well, I may be wrong, I jumped to this conclusion by looking at the difference in quality of your question to complexity of the code.

-P
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You wouldn't parse anything - the SOAP stack does that for you. Your code interacts with the generated classes purely on the level of Java objects and method calls.
 
Mohammed Javeed Basha
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually i have created the webservice, but need to provide soapenvelope request as input and need to retrieve soapenvelope response as output.
Can you please tell me any website name to refer this kind of example, ulf
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic