Quick Web Services question.

Discussion in 'Java' started by dev-jared@shaw.ca, Jul 12, 2005.

  1. Guest

    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") );
    -------------------------------------------------------------------
    ?????? WHAT DO I DO HERE to access the send the doc object and
    receive it back?????
    -------------------------------------------------------------------
    }
    }
    , Jul 12, 2005
    #1
    1. Advertising

  2. Chris Smith Guest

    <> wrote:
    > 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
    Chris Smith, Jul 12, 2005
    #2
    1. Advertising

  3. Guest

    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
    , Jul 13, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nick
    Replies:
    1
    Views:
    6,117
    Alvin Bruney - ASP.NET MVP
    Sep 12, 2005
  2. JKop
    Replies:
    11
    Views:
    873
  3. David Portabella

    Web Services in Java- Quick Start Tutorial

    David Portabella, Jul 9, 2010, in forum: Java
    Replies:
    0
    Views:
    390
    David Portabella
    Jul 9, 2010
  4. John
    Replies:
    4
    Views:
    427
  5. Evgenia

    quick work with files at web-services

    Evgenia, Nov 22, 2006, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    107
    John Saunders
    Nov 22, 2006
Loading...

Share This Page