wood burning stoves 2.0*
The moose likes Web Services and the fly likes Web Services using soap Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Web Services using soap" Watch "Web Services using soap" New topic
Author

Web Services using soap

Mohammed Javeed Basha
Greenhorn

Joined: May 22, 2012
Posts: 9
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
Marshal

Joined: Mar 22, 2005
Posts: 41068
    
  43
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.


Ping & DNS - my free Android networking tools app
Mohammed Javeed Basha
Greenhorn

Joined: May 22, 2012
Posts: 9
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

Joined: Feb 10, 2001
Posts: 614
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


All desirable things in life are either illegal, banned, expensive or married to someone else !!!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41068
    
  43
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

Joined: May 22, 2012
Posts: 9
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
 
subject: Web Services using soap
 
Similar Threads
random xmlns attribute order causing unexpected XML tag exception
Java Client for a SOAP wsdl with basic authentication
JAX-WS: when input soap validation fails
What's Wrong with this simple WSDL
Context injection failed on service access