Quick Web Services question.

D

dev-jared

Hello all,

I am using Apache Axis and am trying to set up a document style
(message based) webservice that will receive a DOM object, modify that
DOM object, and return it as a new DOM object.

I have set up my webservice (a very simple one to get this going):
package testing.webservices;

import org.w3c.dom.Document;
import org.apache.axis.MessageContext;

public class DocTest{
public Document doSubmission(MessageContext msgContext, Document
inDoc)throws Exception{
return inDoc;
}
}

I set this class up in Axis with my deploy.wsdd file:
<deployment name="test" xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">
<service name="DocService" style="java:MSG">
<parameter name="className" value="testing.webservices.DocTest" />
<parameter name="allowedMethods" value="doSubmission" />
</service>
</deployment>

When I look at Axis it lists this DocService as an active service. Can
anyone tell me what the client code would look like to send a Document
object to my simple webservice and receive a document object back? Any
help would be greatly appreciated.

J-Rod

NOTE: This is what I have so far:

import .....

public class DocTestClient{
public static void main(String[] args) throws Exception {
String fileName = "C:\\Dev\\MyXmlFile.xml";
String uri = "file:" + new File(fileName).getAbsolutePath( );
DocumentBuilderFactory factory
=DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(uri);

String endpointURL =
"http://localhost:8080/axis/services/DocService";
Service service = new Service();

Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpointURL) );
call.setOperationName(new QName("http://testing.webservices",
"doSubmission") );
 
C

Chris Smith

I am using Apache Axis and am trying to set up a document style
(message based) webservice that will receive a DOM object, modify that
DOM object, and return it as a new DOM object.
Okay.

When I look at Axis it lists this DocService as an active service. Can
anyone tell me what the client code would look like to send a Document
object to my simple webservice and receive a document object back? Any
help would be greatly appreciated.

You appear to be misinterpreting the Axis "message" style of service.
The "message" service style on the server is just a convenient way to
get the call dispatched to the right method in the normal way, but then
give you low-level access to the SOAP document. The XML stuff that you
receive and return is not an arbitrary XML document, but rather a SOAP
document built from the web service request. If you wish to build the
SOAP document on the client as well, then don't use the stub generator
or any web service libraries on the client at all. Instead, just use
JAXP to build the SOAP request, then send it using HttpURLConnection or
the Jakarta Commons HttpClient package.

The more normal way to do this, though, would be to provide a WSDL
document (which you need to write on your own for a message-style
service, since Axis doesn't have the tools to auto-generate one), and
then generate stubs on the client.

I'm not aware of an easy way to create just the client-side SOAP
envelope and then fill in the contents by hand via DOM. It may be
possible, but I don't know how.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
D

dev-jared

Thanks for your response Chris. You are absolutely right. I was
misunderstanding the Message style object using SOAP envelopes. I ended
up resolving the issue with an RPC string since I only really
interested in a string of XML. Works great now. Thanks for the
clarification.

J-Rod
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top