Hi all,
I've put together some skeleton code for how to implement, publish and
call a document-style SOAP service in Axis beta 2 (thanks for the help
Ramon Turnes). Maybe some of the experts here could check this for me -
hopefully other newbies trying to do document-style SOAP will find it of
some use (I certainly could have used something like it).
I'd be happy to document this properly if someone will give me some
help. I'm still not sure about a few things. For example - is it
possible to have a signature for the method that implements the service
that looks more like:
public Document methodA(Document xml)
rather then the way I've done it:
public Element[] methodA(Vector xml)
I couldn't get the first one to work at all.
I've also got a reponse handler working that takes the body of the
response message - does an XSL transform on it and sticks some extra
information into the message before sending it on to the next handler.
**How to do document style soap calls in Axis beta 2**
**Service Interface**
public interface IMyService
{
public Element[] query(Vector xml)
throws InvalidTradingIntentionFormatException?;
}
**Service Implementation**
public MyServiceImpl implements IMyService
{
public Element[] methodA(Vector xml)
{
Document requestMessage = ((Element)xml.get(0)).getOwnerDocument();
Document responseMessage = ... /* get response message */
Element[] result = new Element[1];
result[0] = responseMessage.getDocumentElement();
return result;
}
}
**Deployment Descriptor**
We deploy the service with the following deployment descriptor:
<deployment xmlns="xml.apache.org/axis/wsdd/"
xmlns:java="xml.apache.org/axis/wsdd/providers/java"
xmlns:xsi="www.w3.org/2000/10/XMLSchema-instance">
<service name="MyService" provider="java:MSG">
<parameter name="className"
value="com.mypackage.MyServiceImpl"/>
<parameter name="allowedMethods" value="methodA"/>
</service>
</deployment>
**Client side code**
public void invokeRemoteMethod(Document messageDoc)
throws Exception
{
// Initialize our Service -
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new
java.net.URL("http://myservername:8080/axis/services/MyService") );
Vector result = null;
Object[] params = new Object[] { new
SOAPBodyElement(messageDoc.getDocumentElement())};
result = (Vector) call.invoke( params );
SOAPBodyElement body = (SOAPBodyElement) result.elementAt(0);
Document resultDoc = body.getAsDocument();
/* do stuff with resultDoc */
}
**The Soap Message**
Here's what the SOAP message looks like:
POST /axis/services/MyService HTTP/1.0
content-Length: 2418
Host: myservername
Content-Type: text/xml; charset=utf-8
SOAPAction: ""
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<!-- my xml document here -->
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
--
Murray Spork
Centre for Information Technology Innovation (CITI)
The Redcone Project
Queensland University of Technology, Brisbane, Australia
Phone: +61-7-3864-9488
Email: [EMAIL PROTECTED]
Web: http://redcone.gbst.com/