You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Rick Reumann <ri...@gmail.com> on 2007/06/13 15:42:41 UTC

Problems trying to send XML as a String to a web service?

I have an Axis2 service set up. It's super simple. I want the user to
be able to send some XML to the service so I figured I'd set up my
POJO service to just accept a String...

public String getResults( String xmlSpec) { ... }

I built my client stubs with java2wsdl (actually used Eclipse's
plugin) and if I pass in a simple String like "Hello World,"
everything is fine. However, when I try to send some XML as a String,
I end up with the service never receiving the XML and get an error
like:

org.apache.axis2.AxisFault: com.ctc.wstx.exc.WstxParsingException:
Unexpected close tag </body>; expected </HR>.
 at [row,col {unknown-source}]: [11,187]
	at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:81)
	at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:356)
	at org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:294)
	at com.nielsen.webservices.SampleWebServiceSampleWebServiceHttpportStub.getResults(SampleWebServiceSampleWebServiceHttpportStub.java:164)
	at com.nielsen.webservices.Client.main(Client.java:31)


I even tried wrapping the String with <![CDATA[ ]]> but it didn't seem
to help. What is the best way to send XML over the wire to an exposed
service?

-- 
Rick

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Problems trying to send XML as a String to a web service?

Posted by Chad DeBauch <cd...@gmail.com>.
Rick...another way you can do this is, put the simple xml in the wsdl, the
web service will then validate and parse the xml.

Chad

On 6/14/07, robert lazarski <ro...@gmail.com> wrote:
>
> Rick, to send a byte array is easy. Try the following:
>
> ArrayList args = new ArrayList();
> String hello = "hello";
> args.add(hello.getBytes());
> OMElement response = sender.invokeBlocking(operationName, args.toArray());
>
> Hint: POJO's use the RPCMessageReceiver. There are unit tests for all the
> receivers. So 'use the source'  ;-) .
>
>
> http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java?revision=526324&view=markup
>
> HTH,
> Robert
>
> On 6/13/07, Rick Reumann <ri...@gmail.com> wrote:
> >
> > I might try that Chad since right now I'm pretty stuck. I wouldn't
> > mind using they byte[] approach but I'm stumped on what to do with the
> > Axis2 client generated stub that wants a DataHandler for the Request
> > object. Looking at the docs
> >
> > http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/activation/DataHandler.html
> > DataHandler wants a DataSource or else Object, String mimetype. The
> > DataSource objects don't seem to have a String implementation so that
> > doesn't help and not sure what to set for object,  or the mimetype.
> >
> > Am I just being really stupid or has it always been this much of a
> > pain to send some simple xml? (I'm still new to using web services so
> > not sure how things were in the past.)  What seems odd is when I
> > google on the issue not a lot comes about it which makes me think I'm
> > just missing something fundamental.
> >
> > Thanks again for the help.
> >
> > On 6/13/07, Chad DeBauch <cd...@gmail.com> wrote:
> > > Another approach I have taken is have the service accept a string like
> > you
> > > originally did but encode it in UTF-8 encoding.  The downside to this
> > is
> > > that clients will need to know that you are expecting a string that is
> > in
> > > UTF-8 encoding.
> > >
> > > Chad
> > >
> > >
> > > On 6/13/07, Rick Reumann <ri...@gmail.com> wrote:
> > > >
> > > > On 6/13/07, robert lazarski <robertlazarski@gmail.com > wrote:
> > > > > I tend to tackle this in two ways: Convert / unconvert the string
> > to
> > > base64
> > > > > and send it that way. Or use mtom and send the string as an
> > attachment.
> > > >
> > > > Thanks Robert. I figured I'd try just using a byte array to start
> > > > with. Maybe someone can help though - I'm a bit unsure how implement
> > > > the client stub that gets generated based off the method:
> > > > getResults(byte[] bytes)
> > > >
> > > > Where I'm running into trouble is that the client stub seems to want
> > > > to use a DataHandler? Instead of dealing with a byte[] it's dealing
> > > > with this DataHandler that I'm unsure how to set this up with my
> > byte
> > > > array?
> > > >
> > > > I have..
> > > > GetResults params = new GetResults();
> > > > params.localBytes = //wants an instance of DataHandler which I'm
> > > > assuming needs my byte[]? but not sure how to set that up
> > > >
> > > > then I can call
> > > > stub.getResults(params);
> > > >
> > > > Thanks for some help.
> > > >
> > > > Original message thread below for reference.
> > > >
> > > > ------------------------------------
> > > >
> > > > > On 6/13/07, Rick Reumann < rickcr@gmail.com> wrote:
> > > > > >
> > > > > > I have an Axis2 service set up. It's super simple. I want the
> > user to
> > > > > > be able to send some XML to the service so I figured I'd set up
> > my
> > > > > > POJO service to just accept a String...
> > > > > >
> > > > > > public String getResults( String xmlSpec) { ... }
> > > > > >
> > > > > > I built my client stubs with java2wsdl (actually used Eclipse's
> > > > > > plugin) and if I pass in a simple String like "Hello World,"
> > > > > > everything is fine. However, when I try to send some XML as a
> > String,
> > > > > > I end up with the service never receiving the XML and get an
> > error
> > > > > > like:
> > > > > >
> > > > > > org.apache.axis2.AxisFault :
> > > > > com.ctc.wstx.exc.WstxParsingException:
> > > > > > Unexpected close tag </body>; expected </HR>.
> > > > > > at [row,col {unknown-source}]: [11,187]
> > > > > >         at
> > > > >
> > > org.apache.axis2.transport.TransportUtils.createSOAPMessage
> > > (TransportUtils.java:81)
> > > > > >         at
> > > > >
> > > org.apache.axis2.description.OutInAxisOperationClient.send(
> > OutInAxisOperation.java:356)
> > > > > >         at
> > > > >
> > > org.apache.axis2.description.OutInAxisOperationClient.execute
> > > > > (OutInAxisOperation.java:294)
> > > > > >         at
> > > > >
> > >
> > com.nielsen.webservices.SampleWebServiceSampleWebServiceHttpportStub.getResults
> > (SampleWebServiceSampleWebServiceHttpportStub.java :164)
> > > > > >         at com.nielsen.webservices.Client.main
> > > > > (Client.java:31)
> > > > > >
> > > > > >
> > > > > > I even tried wrapping the String with <![CDATA[ ]]> but it
> > didn't seem
> > > > > > to help. What is the best way to send XML over the wire to an
> > exposed
> > > > > > service?
> > > > > >
> > > > > > --
> > > > > > Rick
> > > >
> > > >
> > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail:
> > > axis-user-unsubscribe@ws.apache.org
> > > > For additional commands, e-mail: axis-user-help@ws.apache.org
> > > >
> > > >
> > >
> > >
> >
> >
> > --
> > Rick
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> >
> >
>

Re: Problems trying to send XML as a String to a web service?

Posted by robert lazarski <ro...@gmail.com>.
On 6/14/07, Rick Reumann <ri...@gmail.com> wrote:
>
> On 6/14/07, robert lazarski <ro...@gmail.com> wrote:
> ?
> >
> > Sorry, I thought you were using POJO's .
>
> I guess I should be sorry, I must have confused you, I am using POJOS.
> Here is exactly how I started down this bunny trail...
>
> 1) Got requirement for this small demo that we need to call a service
> that takes an xml spec that the client can submit (any platform).
>
> 2) Being new to webservices, figured I'd try Axis2.
>
> 3) Saw the demo of where you create a POJO and then just supply a
> services.xml file that exposes the class.
>
> 4) Deploy the service as deescribed in the docs which creates the wsdl
> for me and everything 'seems' ok. ( I started with a simple method
> that took a string - echo(String myEcho ) { return echo; }
>
> 5) Built the client stubs using wsdl2java and and ran the client and
> all was well (with the echo test).
>
> 6) Then I figured I'd try the same thing as above by passing in XML as
> the String and that's where things began to break down.
>
> It looks like now I should be considering using AXIOM and do things
> with a more manual approach if dealign with a byte[] or else look into
> using one of the attachment protocols?
>
> Right now I'll do whatever would be considered the 'easiest' which is
> also easy for someone on the other end to create their client (ie .net
> or java). Thanks again.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org


Go with WSDL is my advice. It might take you an extra day or two in order to
get started, but it will be time well spent - especially if dealing with
other languages. Get a WSDL validator like WST from eclipse, write a very
simple wsdl with an element like I showed, and that'd be about all you need.
Hint: use document / literal as the wsdl style.

Actually, I did a two minute hack on what you seem to need - you'll have to
google to understand it and be sure to follow the axis2 docs. Also - it
returns a message / code instead of exceptions / faults - its a personal
style that has kept me out of an area that's had trouble at times.

HTH,
Robert

<?xml version="1.0" encoding="UTF-8"?>

<definitions name="ByteSenderService" targetNamespace="http://byteSenderNS"
xmlns:tns="http://byteSenderNS" xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="
http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns2="http://byteSenderNS/types
">
  <types>
    <schema targetNamespace="http://byteSenderNS/types" xmlns:tns="
http://byteSenderNS/types" xmlns:soap11-enc="
http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="
http://schemas.xmlsoap.org/wsdl/" xmlns="http://www.w3.org/2001/XMLSchema">
      <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
      <complexType name="ReturnWebBase">
        <sequence>
          <element name="errorMessage" type="xsd:string"/>
          <element name="successErrorCode" type="xsd:int"/>
        </sequence>
      </complexType>
      <element name="ByteSender">
        <complexType>
          <sequence>
            <element name="myBytes" type="xsd:base64Binary"/>
          </sequence>
        </complexType>
      </element>
      <element name="ReturnWebBaseResponse" type="ns2:ReturnWebBase"/>
</schema></types>
  <message name="ByteSenderEndpoint_ByteSender">
    <part name="parameters" element="ns2:ByteSender"/>
  </message>
  <message name="ByteSenderEndpoint_ByteSenderResponse">
    <part name="result" element="ns2:ReturnWebBaseResponse"/>
  </message>
  <portType name="ByteSenderEndpoint">
    <operation name="ByteSender">
      <input message="tns:ByteSenderEndpoint_ByteSender"
name="ByteSenderEndpoint_ByteSender"/>
      <output message="tns:ByteSenderEndpoint_ByteSenderResponse"
name="ByteSenderEndpoint_ByteSenderResponse"/>
    </operation>
  </portType>
  <binding name="ByteSenderEndpointBinding" type="tns:ByteSenderEndpoint">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document"/>
    <operation name="ByteSender">
      <soap:operation soapAction="ByteSender"/>
      <input name="ByteSenderEndpoint_ByteSender">
        <soap:body use="literal"/>
      </input>
      <output name="ByteSenderEndpoint_ByteSenderResponse">
        <soap:body use="literal"/>
      </output>
    </operation>
  </binding>
  <service name="ByteSenderService">
    <port name="ByteSenderEndpointPort"
binding="tns:ByteSenderEndpointBinding">
      <soap:address location="
http://localhost:8080/axis2/services/ByteSenderEndpoint
"/></port></service></definitions>

Re: Problems trying to send XML as a String to a web service?

Posted by Rick Reumann <ri...@gmail.com>.
On 6/14/07, robert lazarski <ro...@gmail.com> wrote:
 ?
>
> Sorry, I thought you were using POJO's .

I guess I should be sorry, I must have confused you, I am using POJOS.
Here is exactly how I started down this bunny trail...

1) Got requirement for this small demo that we need to call a service
that takes an xml spec that the client can submit (any platform).

2) Being new to webservices, figured I'd try Axis2.

3) Saw the demo of where you create a POJO and then just supply a
services.xml file that exposes the class.

4) Deploy the service as deescribed in the docs which creates the wsdl
for me and everything 'seems' ok. ( I started with a simple method
that took a string - echo(String myEcho ) { return echo; }

5) Built the client stubs using wsdl2java and and ran the client and
all was well (with the echo test).

6) Then I figured I'd try the same thing as above by passing in XML as
the String and that's where things began to break down.

It looks like now I should be considering using AXIOM and do things
with a more manual approach if dealign with a byte[] or else look into
using one of the attachment protocols?

Right now I'll do whatever would be considered the 'easiest' which is
also easy for someone on the other end to create their client (ie .net
or java). Thanks again.

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Problems trying to send XML as a String to a web service?

Posted by robert lazarski <ro...@gmail.com>.
On 6/14/07, Rick Reumann <ri...@gmail.com> wrote:
>
> On 6/14/07, robert lazarski <ro...@gmail.com> wrote:
> > Rick, to send a byte array is easy. Try the following:
> >
> > ArrayList args = new ArrayList();
> > String hello = "hello";
> > args.add(hello.getBytes());
> > OMElement response = sender.invokeBlocking(operationName, args.toArray
> ());
> >
> > Hint: POJO's use the RPCMessageReceiver. There are unit tests for all
> the
> > receivers. So 'use the source'  ;-) .
> >
> >
> http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java?revision=526324&view=markup
>
> Thanks Robert (and others) for the help. So am I too assume you can't
> just use wsdl2java to create client stubs that will work for sending a
> byte[]? I was assuming I could take the easy way out of simply
> generating easy to use stubs - apparently I now have to learn more
> about what's really going on 'behind the scenes' and send it in a more
> low-level way?


Sorry, I thought you were using POJO's . I think mentioned using base64.
Doing this though wsdl would be sort of like:

   <element name="RCZipperRecieveZip">
        <complexType>
          <sequence>
            <element name="zipfile" type="xsd:base64Binary"/>
          </sequence>
        </complexType>
    </element>

The code would then be:

File file = new File(filePath);
byte[] fileBytes = Utils.getBytesFromFile(file);
rcZipperRecieveZip.setZipfile(fileBytes);

As I think I stated, you could reduce the size of the payload about by about
a third via mtom - the above code was used long ago, before mtom became
stable.

HTH,
Robert



---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

Re: Problems trying to send XML as a String to a web service?

Posted by Rick Reumann <ri...@gmail.com>.
On 6/14/07, robert lazarski <ro...@gmail.com> wrote:
> Rick, to send a byte array is easy. Try the following:
>
> ArrayList args = new ArrayList();
> String hello = "hello";
> args.add(hello.getBytes());
> OMElement response = sender.invokeBlocking(operationName, args.toArray());
>
> Hint: POJO's use the RPCMessageReceiver. There are unit tests for all the
> receivers. So 'use the source'  ;-) .
>
> http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java?revision=526324&view=markup

Thanks Robert (and others) for the help. So am I too assume you can't
just use wsdl2java to create client stubs that will work for sending a
byte[]? I was assuming I could take the easy way out of simply
generating easy to use stubs - apparently I now have to learn more
about what's really going on 'behind the scenes' and send it in a more
low-level way?

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Problems trying to send XML as a String to a web service?

Posted by robert lazarski <ro...@gmail.com>.
Rick, to send a byte array is easy. Try the following:

ArrayList args = new ArrayList();
String hello = "hello";
args.add(hello.getBytes());
OMElement response = sender.invokeBlocking(operationName, args.toArray());

Hint: POJO's use the RPCMessageReceiver. There are unit tests for all the
receivers. So 'use the source'  ;-) .

http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java?revision=526324&view=markup

HTH,
Robert

On 6/13/07, Rick Reumann <ri...@gmail.com> wrote:
>
> I might try that Chad since right now I'm pretty stuck. I wouldn't
> mind using they byte[] approach but I'm stumped on what to do with the
> Axis2 client generated stub that wants a DataHandler for the Request
> object. Looking at the docs
>
> http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/activation/DataHandler.html
> DataHandler wants a DataSource or else Object, String mimetype. The
> DataSource objects don't seem to have a String implementation so that
> doesn't help and not sure what to set for object,  or the mimetype.
>
> Am I just being really stupid or has it always been this much of a
> pain to send some simple xml? (I'm still new to using web services so
> not sure how things were in the past.)  What seems odd is when I
> google on the issue not a lot comes about it which makes me think I'm
> just missing something fundamental.
>
> Thanks again for the help.
>
> On 6/13/07, Chad DeBauch <cd...@gmail.com> wrote:
> > Another approach I have taken is have the service accept a string like
> you
> > originally did but encode it in UTF-8 encoding.  The downside to this is
> > that clients will need to know that you are expecting a string that is
> in
> > UTF-8 encoding.
> >
> > Chad
> >
> >
> > On 6/13/07, Rick Reumann <ri...@gmail.com> wrote:
> > >
> > > On 6/13/07, robert lazarski <ro...@gmail.com> wrote:
> > > > I tend to tackle this in two ways: Convert / unconvert the string to
> > base64
> > > > and send it that way. Or use mtom and send the string as an
> attachment.
> > >
> > > Thanks Robert. I figured I'd try just using a byte array to start
> > > with. Maybe someone can help though - I'm a bit unsure how implement
> > > the client stub that gets generated based off the method:
> > > getResults(byte[] bytes)
> > >
> > > Where I'm running into trouble is that the client stub seems to want
> > > to use a DataHandler? Instead of dealing with a byte[] it's dealing
> > > with this DataHandler that I'm unsure how to set this up with my byte
> > > array?
> > >
> > > I have..
> > > GetResults params = new GetResults();
> > > params.localBytes = //wants an instance of DataHandler which I'm
> > > assuming needs my byte[]? but not sure how to set that up
> > >
> > > then I can call
> > > stub.getResults(params);
> > >
> > > Thanks for some help.
> > >
> > > Original message thread below for reference.
> > >
> > > ------------------------------------
> > >
> > > > On 6/13/07, Rick Reumann < rickcr@gmail.com> wrote:
> > > > >
> > > > > I have an Axis2 service set up. It's super simple. I want the user
> to
> > > > > be able to send some XML to the service so I figured I'd set up my
> > > > > POJO service to just accept a String...
> > > > >
> > > > > public String getResults( String xmlSpec) { ... }
> > > > >
> > > > > I built my client stubs with java2wsdl (actually used Eclipse's
> > > > > plugin) and if I pass in a simple String like "Hello World,"
> > > > > everything is fine. However, when I try to send some XML as a
> String,
> > > > > I end up with the service never receiving the XML and get an error
> > > > > like:
> > > > >
> > > > > org.apache.axis2.AxisFault :
> > > > com.ctc.wstx.exc.WstxParsingException:
> > > > > Unexpected close tag </body>; expected </HR>.
> > > > > at [row,col {unknown-source}]: [11,187]
> > > > >         at
> > > >
> > org.apache.axis2.transport.TransportUtils.createSOAPMessage
> > (TransportUtils.java:81)
> > > > >         at
> > > >
> > org.apache.axis2.description.OutInAxisOperationClient.send(
> OutInAxisOperation.java:356)
> > > > >         at
> > > >
> > org.apache.axis2.description.OutInAxisOperationClient.execute
> > > > (OutInAxisOperation.java:294)
> > > > >         at
> > > >
> >
> com.nielsen.webservices.SampleWebServiceSampleWebServiceHttpportStub.getResults
> (SampleWebServiceSampleWebServiceHttpportStub.java:164)
> > > > >         at com.nielsen.webservices.Client.main
> > > > (Client.java:31)
> > > > >
> > > > >
> > > > > I even tried wrapping the String with <![CDATA[ ]]> but it didn't
> seem
> > > > > to help. What is the best way to send XML over the wire to an
> exposed
> > > > > service?
> > > > >
> > > > > --
> > > > > Rick
> > >
> > >
> > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > axis-user-unsubscribe@ws.apache.org
> > > For additional commands, e-mail: axis-user-help@ws.apache.org
> > >
> > >
> >
> >
>
>
> --
> Rick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

Re: Problems trying to send XML as a String to a web service?

Posted by Rick Reumann <ri...@gmail.com>.
I might try that Chad since right now I'm pretty stuck. I wouldn't
mind using they byte[] approach but I'm stumped on what to do with the
Axis2 client generated stub that wants a DataHandler for the Request
object. Looking at the docs
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/activation/DataHandler.html
DataHandler wants a DataSource or else Object, String mimetype. The
DataSource objects don't seem to have a String implementation so that
doesn't help and not sure what to set for object,  or the mimetype.

Am I just being really stupid or has it always been this much of a
pain to send some simple xml? (I'm still new to using web services so
not sure how things were in the past.)  What seems odd is when I
google on the issue not a lot comes about it which makes me think I'm
just missing something fundamental.

Thanks again for the help.

On 6/13/07, Chad DeBauch <cd...@gmail.com> wrote:
> Another approach I have taken is have the service accept a string like you
> originally did but encode it in UTF-8 encoding.  The downside to this is
> that clients will need to know that you are expecting a string that is in
> UTF-8 encoding.
>
> Chad
>
>
> On 6/13/07, Rick Reumann <ri...@gmail.com> wrote:
> >
> > On 6/13/07, robert lazarski <ro...@gmail.com> wrote:
> > > I tend to tackle this in two ways: Convert / unconvert the string to
> base64
> > > and send it that way. Or use mtom and send the string as an attachment.
> >
> > Thanks Robert. I figured I'd try just using a byte array to start
> > with. Maybe someone can help though - I'm a bit unsure how implement
> > the client stub that gets generated based off the method:
> > getResults(byte[] bytes)
> >
> > Where I'm running into trouble is that the client stub seems to want
> > to use a DataHandler? Instead of dealing with a byte[] it's dealing
> > with this DataHandler that I'm unsure how to set this up with my byte
> > array?
> >
> > I have..
> > GetResults params = new GetResults();
> > params.localBytes = //wants an instance of DataHandler which I'm
> > assuming needs my byte[]? but not sure how to set that up
> >
> > then I can call
> > stub.getResults(params);
> >
> > Thanks for some help.
> >
> > Original message thread below for reference.
> >
> > ------------------------------------
> >
> > > On 6/13/07, Rick Reumann < rickcr@gmail.com> wrote:
> > > >
> > > > I have an Axis2 service set up. It's super simple. I want the user to
> > > > be able to send some XML to the service so I figured I'd set up my
> > > > POJO service to just accept a String...
> > > >
> > > > public String getResults( String xmlSpec) { ... }
> > > >
> > > > I built my client stubs with java2wsdl (actually used Eclipse's
> > > > plugin) and if I pass in a simple String like "Hello World,"
> > > > everything is fine. However, when I try to send some XML as a String,
> > > > I end up with the service never receiving the XML and get an error
> > > > like:
> > > >
> > > > org.apache.axis2.AxisFault :
> > > com.ctc.wstx.exc.WstxParsingException:
> > > > Unexpected close tag </body>; expected </HR>.
> > > > at [row,col {unknown-source}]: [11,187]
> > > >         at
> > >
> org.apache.axis2.transport.TransportUtils.createSOAPMessage
> (TransportUtils.java:81)
> > > >         at
> > >
> org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:356)
> > > >         at
> > >
> org.apache.axis2.description.OutInAxisOperationClient.execute
> > > (OutInAxisOperation.java:294)
> > > >         at
> > >
> com.nielsen.webservices.SampleWebServiceSampleWebServiceHttpportStub.getResults(SampleWebServiceSampleWebServiceHttpportStub.java:164)
> > > >         at com.nielsen.webservices.Client.main
> > > (Client.java:31)
> > > >
> > > >
> > > > I even tried wrapping the String with <![CDATA[ ]]> but it didn't seem
> > > > to help. What is the best way to send XML over the wire to an exposed
> > > > service?
> > > >
> > > > --
> > > > Rick
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> >
> >
>
>


-- 
Rick

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Problems trying to send XML as a String to a web service?

Posted by Rick Reumann <ri...@gmail.com>.
On 6/13/07, Xinjun Chen <xj...@gmail.com> wrote:
> The solution I adopted is to use CDATA instead of string. You don't need to
> do escaping by yourself.

Your saying use the jdom CDATA object as the service method argument?
I wouldn't think this would be a good idea since how would the client
generated stubs on some other platform (like .NET) know how to deal
with this type of object? I actually thought about taking a Document
object but not sure how that would work cross platform as well.

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Problems trying to send XML as a String to a web service?

Posted by Xinjun Chen <xj...@gmail.com>.
The solution I adopted is to use CDATA instead of string. You don't need to
do escaping by yourself.

Regards,
Xinjun

On 6/14/07, Chad DeBauch <cd...@gmail.com> wrote:
>
> Another approach I have taken is have the service accept a string like you
> originally did but encode it in UTF-8 encoding.  The downside to this is
> that clients will need to know that you are expecting a string that is in
> UTF-8 encoding.
>
> Chad
>
> On 6/13/07, Rick Reumann <ri...@gmail.com> wrote:
> >
> > On 6/13/07, robert lazarski <ro...@gmail.com> wrote:
> > > I tend to tackle this in two ways: Convert / unconvert the string to
> > base64
> > > and send it that way. Or use mtom and send the string as an
> > attachment.
> >
> > Thanks Robert. I figured I'd try just using a byte array to start
> > with. Maybe someone can help though - I'm a bit unsure how implement
> > the client stub that gets generated based off the method:
> > getResults(byte[] bytes)
> >
> > Where I'm running into trouble is that the client stub seems to want
> > to use a DataHandler? Instead of dealing with a byte[] it's dealing
> > with this DataHandler that I'm unsure how to set this up with my byte
> > array?
> >
> > I have..
> > GetResults params = new GetResults();
> > params.localBytes = //wants an instance of DataHandler which I'm
> > assuming needs my byte[]? but not sure how to set that up
> >
> > then I can call
> > stub.getResults(params);
> >
> > Thanks for some help.
> >
> > Original message thread below for reference.
> >
> > ------------------------------------
> >
> > > On 6/13/07, Rick Reumann < rickcr@gmail.com> wrote:
> > > >
> > > > I have an Axis2 service set up. It's super simple. I want the user
> > to
> > > > be able to send some XML to the service so I figured I'd set up my
> > > > POJO service to just accept a String...
> > > >
> > > > public String getResults( String xmlSpec) { ... }
> > > >
> > > > I built my client stubs with java2wsdl (actually used Eclipse's
> > > > plugin) and if I pass in a simple String like "Hello World,"
> > > > everything is fine. However, when I try to send some XML as a
> > String,
> > > > I end up with the service never receiving the XML and get an error
> > > > like:
> > > >
> > > > org.apache.axis2.AxisFault :
> > > com.ctc.wstx.exc.WstxParsingException:
> > > > Unexpected close tag </body>; expected </HR>.
> > > > at [row,col {unknown-source}]: [11,187]
> > > >         at
> > > org.apache.axis2.transport.TransportUtils.createSOAPMessage (
> > TransportUtils.java:81)
> > > >         at
> > > org.apache.axis2.description.OutInAxisOperationClient.send(
> > OutInAxisOperation.java:356)
> > > >         at
> > > org.apache.axis2.description.OutInAxisOperationClient.execute
> > > (OutInAxisOperation.java:294)
> > > >         at
> > >
> > com.nielsen.webservices.SampleWebServiceSampleWebServiceHttpportStub.getResults
> > (SampleWebServiceSampleWebServiceHttpportStub.java:164)
> > > >         at com.nielsen.webservices.Client.main
> > > (Client.java:31)
> > > >
> > > >
> > > > I even tried wrapping the String with <![CDATA[ ]]> but it didn't
> > seem
> > > > to help. What is the best way to send XML over the wire to an
> > exposed
> > > > service?
> > > >
> > > > --
> > > > Rick
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> >
> >
>

Re: Problems trying to send XML as a String to a web service?

Posted by Chad DeBauch <cd...@gmail.com>.
Another approach I have taken is have the service accept a string like you
originally did but encode it in UTF-8 encoding.  The downside to this is
that clients will need to know that you are expecting a string that is in
UTF-8 encoding.

Chad

On 6/13/07, Rick Reumann <ri...@gmail.com> wrote:
>
> On 6/13/07, robert lazarski <ro...@gmail.com> wrote:
> > I tend to tackle this in two ways: Convert / unconvert the string to
> base64
> > and send it that way. Or use mtom and send the string as an attachment.
>
> Thanks Robert. I figured I'd try just using a byte array to start
> with. Maybe someone can help though - I'm a bit unsure how implement
> the client stub that gets generated based off the method:
> getResults(byte[] bytes)
>
> Where I'm running into trouble is that the client stub seems to want
> to use a DataHandler? Instead of dealing with a byte[] it's dealing
> with this DataHandler that I'm unsure how to set this up with my byte
> array?
>
> I have..
> GetResults params = new GetResults();
> params.localBytes = //wants an instance of DataHandler which I'm
> assuming needs my byte[]? but not sure how to set that up
>
> then I can call
> stub.getResults(params);
>
> Thanks for some help.
>
> Original message thread below for reference.
>
> ------------------------------------
>
> > On 6/13/07, Rick Reumann <ri...@gmail.com> wrote:
> > >
> > > I have an Axis2 service set up. It's super simple. I want the user to
> > > be able to send some XML to the service so I figured I'd set up my
> > > POJO service to just accept a String...
> > >
> > > public String getResults( String xmlSpec) { ... }
> > >
> > > I built my client stubs with java2wsdl (actually used Eclipse's
> > > plugin) and if I pass in a simple String like "Hello World,"
> > > everything is fine. However, when I try to send some XML as a String,
> > > I end up with the service never receiving the XML and get an error
> > > like:
> > >
> > > org.apache.axis2.AxisFault:
> > com.ctc.wstx.exc.WstxParsingException:
> > > Unexpected close tag </body>; expected </HR>.
> > > at [row,col {unknown-source}]: [11,187]
> > >         at
> > org.apache.axis2.transport.TransportUtils.createSOAPMessage(
> TransportUtils.java:81)
> > >         at
> > org.apache.axis2.description.OutInAxisOperationClient.send(
> OutInAxisOperation.java:356)
> > >         at
> > org.apache.axis2.description.OutInAxisOperationClient.execute
> > (OutInAxisOperation.java:294)
> > >         at
> >
> com.nielsen.webservices.SampleWebServiceSampleWebServiceHttpportStub.getResults
> (SampleWebServiceSampleWebServiceHttpportStub.java:164)
> > >         at com.nielsen.webservices.Client.main
> > (Client.java:31)
> > >
> > >
> > > I even tried wrapping the String with <![CDATA[ ]]> but it didn't seem
> > > to help. What is the best way to send XML over the wire to an exposed
> > > service?
> > >
> > > --
> > > Rick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

Re: Problems trying to send XML as a String to a web service?

Posted by Rick Reumann <ri...@gmail.com>.
On 6/13/07, robert lazarski <ro...@gmail.com> wrote:
> I tend to tackle this in two ways: Convert / unconvert the string to base64
> and send it that way. Or use mtom and send the string as an attachment.

Thanks Robert. I figured I'd try just using a byte array to start
with. Maybe someone can help though - I'm a bit unsure how implement
the client stub that gets generated based off the method:
getResults(byte[] bytes)

Where I'm running into trouble is that the client stub seems to want
to use a DataHandler? Instead of dealing with a byte[] it's dealing
with this DataHandler that I'm unsure how to set this up with my byte
array?

I have..
GetResults params = new GetResults();
params.localBytes = //wants an instance of DataHandler which I'm
assuming needs my byte[]? but not sure how to set that up

then I can call
stub.getResults(params);

Thanks for some help.

Original message thread below for reference.

------------------------------------

> On 6/13/07, Rick Reumann <ri...@gmail.com> wrote:
> >
> > I have an Axis2 service set up. It's super simple. I want the user to
> > be able to send some XML to the service so I figured I'd set up my
> > POJO service to just accept a String...
> >
> > public String getResults( String xmlSpec) { ... }
> >
> > I built my client stubs with java2wsdl (actually used Eclipse's
> > plugin) and if I pass in a simple String like "Hello World,"
> > everything is fine. However, when I try to send some XML as a String,
> > I end up with the service never receiving the XML and get an error
> > like:
> >
> > org.apache.axis2.AxisFault:
> com.ctc.wstx.exc.WstxParsingException:
> > Unexpected close tag </body>; expected </HR>.
> > at [row,col {unknown-source}]: [11,187]
> >         at
> org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:81)
> >         at
> org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:356)
> >         at
> org.apache.axis2.description.OutInAxisOperationClient.execute
> (OutInAxisOperation.java:294)
> >         at
> com.nielsen.webservices.SampleWebServiceSampleWebServiceHttpportStub.getResults(SampleWebServiceSampleWebServiceHttpportStub.java:164)
> >         at com.nielsen.webservices.Client.main
> (Client.java:31)
> >
> >
> > I even tried wrapping the String with <![CDATA[ ]]> but it didn't seem
> > to help. What is the best way to send XML over the wire to an exposed
> > service?
> >
> > --
> > Rick

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Problems trying to send XML as a String to a web service?

Posted by robert lazarski <ro...@gmail.com>.
I tend to tackle this in two ways: Convert / unconvert the string to base64
and send it that way. Or use mtom and send the string as an attachment.

Someone else may be able to comment on getting the actual string escaped
correctly inside the soap body, but I tend not to bother.

HTH,
Robert

On 6/13/07, Rick Reumann <ri...@gmail.com> wrote:
>
> I have an Axis2 service set up. It's super simple. I want the user to
> be able to send some XML to the service so I figured I'd set up my
> POJO service to just accept a String...
>
> public String getResults( String xmlSpec) { ... }
>
> I built my client stubs with java2wsdl (actually used Eclipse's
> plugin) and if I pass in a simple String like "Hello World,"
> everything is fine. However, when I try to send some XML as a String,
> I end up with the service never receiving the XML and get an error
> like:
>
> org.apache.axis2.AxisFault: com.ctc.wstx.exc.WstxParsingException:
> Unexpected close tag </body>; expected </HR>.
> at [row,col {unknown-source}]: [11,187]
>         at org.apache.axis2.transport.TransportUtils.createSOAPMessage(
> TransportUtils.java:81)
>         at org.apache.axis2.description.OutInAxisOperationClient.send(
> OutInAxisOperation.java:356)
>         at org.apache.axis2.description.OutInAxisOperationClient.execute(
> OutInAxisOperation.java:294)
>         at
> com.nielsen.webservices.SampleWebServiceSampleWebServiceHttpportStub.getResults
> (SampleWebServiceSampleWebServiceHttpportStub.java:164)
>         at com.nielsen.webservices.Client.main(Client.java:31)
>
>
> I even tried wrapping the String with <![CDATA[ ]]> but it didn't seem
> to help. What is the best way to send XML over the wire to an exposed
> service?
>
> --
> Rick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

RE: Problems trying to send XML as a String to a web service?

Posted by "Rudolph, Troy" <Tr...@ca.com>.
The XML string that I send from the service to the client can be quite
long.  So, I compress it and send it to the client as an attachment via
MTOM.  Works great!

-----Original Message-----
From: Rick Reumann [mailto:rickcr@gmail.com] 
Sent: Wednesday, June 13, 2007 8:43 AM
To: axis-user@ws.apache.org
Subject: Problems trying to send XML as a String to a web service?

I have an Axis2 service set up. It's super simple. I want the user to be
able to send some XML to the service so I figured I'd set up my POJO
service to just accept a String...

public String getResults( String xmlSpec) { ... }

I built my client stubs with java2wsdl (actually used Eclipse's
plugin) and if I pass in a simple String like "Hello World,"
everything is fine. However, when I try to send some XML as a String, I
end up with the service never receiving the XML and get an error
like:

org.apache.axis2.AxisFault: com.ctc.wstx.exc.WstxParsingException:
Unexpected close tag </body>; expected </HR>.
 at [row,col {unknown-source}]: [11,187]
	at
org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUti
ls.java:81)
	at
org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOper
ation.java:356)
	at
org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisO
peration.java:294)
	at
com.nielsen.webservices.SampleWebServiceSampleWebServiceHttpportStub.get
Results(SampleWebServiceSampleWebServiceHttpportStub.java:164)
	at com.nielsen.webservices.Client.main(Client.java:31)


I even tried wrapping the String with <![CDATA[ ]]> but it didn't seem
to help. What is the best way to send XML over the wire to an exposed
service?

--
Rick

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org