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 Satyajit Jha <sa...@gmail.com> on 2006/09/21 21:45:09 UTC

[Axis2] Problem in passing XML data as String parameter

Hi,

I am using a stub client generated from wsdl using axis wsdl2java. I am
trying to execute an operation with a string parameter. When I try to pass
some XML data fragment as string for that parameter, it gives me "HTTP
Transport error : '400' - 'Bad Request' " error. I looked at the SOAP
request being generated. The '<' character in the XML string that I passed
was modified into &lt;. Now this happens, I believe,  because the stub code
is using XMLStreamWriter.writeCharacters() on the XML string which doesn't
accept any such character in the string. Now I dont know how I should
resolve this problem. Is there anyway in which I can pass an XML data as
string parameter. I will appreciate any help.

Regards,
Satyajit

Re: [Axis2] Problem in passing XML data as String parameter

Posted by Dennis Sosnoski <dm...@sosnoski.com>.
XML doesn't require the '>' character to be escaped, except in some 
particular conditions (when following "]]"). I don't see anything wrong 
with the escaping being done here.

 From what you said, I'd suspect that the service really expects you to 
use an <HTMLFragment> child element, as in Anne's second example. If 
this is included in the schema the generated code should provide a way 
to set this. Can you point us at the WSDL and schema?

  - Dennis

Dennis M. Sosnoski
SOA, Web Services, and XML
Training and Consulting
http://www.sosnoski.com - http://www.sosnoski.co.nz
Seattle, WA +1-425-296-6194 - Wellington, NZ +64-4-298-6117



Anne Thomas Manes wrote:
> The problem is that it's only partially escaping the fragment for you.
> You want the message to read either:
>
>    
> <ns1:DeviceInfo>&lt;HTMLFragment&gt;True&lt;/HTMLFragment&gt;</ns1:DeviceInfo> 
>
>
> (which is how it should be if you are sending the value as a string) or
>
>    <ns1:DeviceInfo><HTMLFragment>True</HTMLFragment></ns1:DeviceInfo>
>
> (which is sending the data as XML)
>
> Anne
>
> On 9/22/06, Satyajit Jha <sa...@gmail.com> wrote:
>> Hi Anne,
>>
>> Thanks for your response.
>>
>> I do believe that the problem is due to the reasons I mentioned. I 
>> will try
>> to provide a context here. I am using axis2 generated client stub for
>> accessing MS Reporting Service  (MSRS) 2005 web service. I am trying to
>> render HTML reports using this and I am able to do that. Now I want
>> HTMLFragment (just the table, without html and body tag) from the 
>> report.
>> MSRS lets me do this by setting a parameter (DeviceInfo) of render 
>> operation
>> to "<HTMLFragment>True</HTMLFragment>". When I pass this
>> value in setDeviceInfo method of Render, I get following SOAP-body in my
>> request message.
>>
>> <soapenv:Body><ns1:Render
>> xmlns:ns1="http://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices 
>>
>> ">
>> <ns1:Format>HTML4.0</ns1:Format>
>> <ns1:DeviceInfo>&lt;HTMLFragment>True&lt;/HTMLFragment></ns1:DeviceInfo>
>> </ns1:Render></soapenv:Body>
>>
>> And this must be a bad request. Please let me know if you have any 
>> idea on
>> how to avoid this problem.
>>
>> Thanks,
>> Satyajit
>>
>>
>> On 9/23/06, Anne Thomas Manes <at...@gmail.com> wrote:
>> >
>> > It depends on the characters in your data. Converting the '<' to
>> > '&lt;' is expected, but that's probably not what's causing your
>> > problem. You might have characters in the document that can't be
>> > properly escaped. If that's the case, you may not be able to send the
>> > data as a string. Why not just send the XML data as XML data?
>> >
>> > Anne
>> >
>> > On 9/21/06, Satyajit Jha <sa...@gmail.com> wrote:
>> > > Hi,
>> > >
>> > > I am using a stub client generated from wsdl using axis 
>> wsdl2java. I am
>> > > trying to execute an operation with a string parameter. When I 
>> try to
>> pass
>> > > some XML data fragment as string for that parameter, it gives me 
>> "HTTP
>> > > Transport error : '400' - 'Bad Request' " error. I looked at the 
>> SOAP
>> > > request being generated. The '<' character in the XML string that I
>> passed
>> > > was modified into &lt;. Now this happens, I believe,  because the 
>> stub
>> code
>> > > is using XMLStreamWriter.writeCharacters () on the XML string which
>> doesn't
>> > > accept any such character in the string. Now I dont know how I 
>> should
>> > > resolve this problem. Is there anyway in which I can pass an XML 
>> data as
>> > > string parameter. I will appreciate any help.
>> > >
>> > > Regards,
>> > > Satyajit
>> > >
>> >
>> >
>> ---------------------------------------------------------------------
>> > 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
>

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


Re: [Axis2] Problem in passing XML data as String parameter

Posted by Anne Thomas Manes <at...@gmail.com>.
The problem is that it's only partially escaping the fragment for you.
You want the message to read either:

    <ns1:DeviceInfo>&lt;HTMLFragment&gt;True&lt;/HTMLFragment&gt;</ns1:DeviceInfo>

(which is how it should be if you are sending the value as a string) or

    <ns1:DeviceInfo><HTMLFragment>True</HTMLFragment></ns1:DeviceInfo>

(which is sending the data as XML)

Anne

On 9/22/06, Satyajit Jha <sa...@gmail.com> wrote:
> Hi Anne,
>
> Thanks for your response.
>
> I do believe that the problem is due to the reasons I mentioned. I will try
> to provide a context here. I am using axis2 generated client stub for
> accessing MS Reporting Service  (MSRS) 2005 web service. I am trying to
> render HTML reports using this and I am able to do that. Now I want
> HTMLFragment (just the table, without html and body tag) from the report.
> MSRS lets me do this by setting a parameter (DeviceInfo) of render operation
> to "<HTMLFragment>True</HTMLFragment>". When I pass this
> value in setDeviceInfo method of Render, I get following SOAP-body in my
> request message.
>
> <soapenv:Body><ns1:Render
> xmlns:ns1="http://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices
> ">
> <ns1:Format>HTML4.0</ns1:Format>
> <ns1:DeviceInfo>&lt;HTMLFragment>True&lt;/HTMLFragment></ns1:DeviceInfo>
> </ns1:Render></soapenv:Body>
>
> And this must be a bad request. Please let me know if you have any idea on
> how to avoid this problem.
>
> Thanks,
> Satyajit
>
>
> On 9/23/06, Anne Thomas Manes <at...@gmail.com> wrote:
> >
> > It depends on the characters in your data. Converting the '<' to
> > '&lt;' is expected, but that's probably not what's causing your
> > problem. You might have characters in the document that can't be
> > properly escaped. If that's the case, you may not be able to send the
> > data as a string. Why not just send the XML data as XML data?
> >
> > Anne
> >
> > On 9/21/06, Satyajit Jha <sa...@gmail.com> wrote:
> > > Hi,
> > >
> > > I am using a stub client generated from wsdl using axis wsdl2java. I am
> > > trying to execute an operation with a string parameter. When I try to
> pass
> > > some XML data fragment as string for that parameter, it gives me "HTTP
> > > Transport error : '400' - 'Bad Request' " error. I looked at the SOAP
> > > request being generated. The '<' character in the XML string that I
> passed
> > > was modified into &lt;. Now this happens, I believe,  because the stub
> code
> > > is using XMLStreamWriter.writeCharacters () on the XML string which
> doesn't
> > > accept any such character in the string. Now I dont know how I should
> > > resolve this problem. Is there anyway in which I can pass an XML data as
> > > string parameter. I will appreciate any help.
> > >
> > > Regards,
> > > Satyajit
> > >
> >
> >
> ---------------------------------------------------------------------
> > 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


Re: [Axis2] Problem in passing XML data as String parameter

Posted by Satyajit Jha <sa...@gmail.com>.
Hi Anne,

Thanks for your response.

I do believe that the problem is due to the reasons I mentioned. I will try
to provide a context here. I am using axis2 generated client stub for
accessing MS Reporting Service  (MSRS) 2005 web service. I am trying to
render HTML reports using this and I am able to do that. Now I want
HTMLFragment (just the table, without html and body tag) from the report.
MSRS lets me do this by setting a parameter (DeviceInfo) of render operation
to "<HTMLFragment>True</HTMLFragment>". When I pass this value in
setDeviceInfo method of Render, I get following SOAP-body in my request
message.

<soapenv:Body><ns1:Render xmlns:ns1="
http://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices
">
<ns1:Format>HTML4.0</ns1:Format>
<ns1:DeviceInfo>&lt;HTMLFragment>True&lt;/HTMLFragment></ns1:DeviceInfo>
</ns1:Render></soapenv:Body>

And this must be a bad request. Please let me know if you have any idea on
how to avoid this problem.

Thanks,
Satyajit

On 9/23/06, Anne Thomas Manes <at...@gmail.com> wrote:
>
> It depends on the characters in your data. Converting the '<' to
> '&lt;' is expected, but that's probably not what's causing your
> problem. You might have characters in the document that can't be
> properly escaped. If that's the case, you may not be able to send the
> data as a string. Why not just send the XML data as XML data?
>
> Anne
>
> On 9/21/06, Satyajit Jha <sa...@gmail.com> wrote:
> > Hi,
> >
> > I am using a stub client generated from wsdl using axis wsdl2java. I am
> > trying to execute an operation with a string parameter. When I try to
> pass
> > some XML data fragment as string for that parameter, it gives me "HTTP
> > Transport error : '400' - 'Bad Request' " error. I looked at the SOAP
> > request being generated. The '<' character in the XML string that I
> passed
> > was modified into &lt;. Now this happens, I believe,  because the stub
> code
> > is using XMLStreamWriter.writeCharacters() on the XML string which
> doesn't
> > accept any such character in the string. Now I dont know how I should
> > resolve this problem. Is there anyway in which I can pass an XML data as
> > string parameter. I will appreciate any help.
> >
> > Regards,
> > Satyajit
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

Re: [Axis2] Problem in passing XML data as String parameter

Posted by Anne Thomas Manes <at...@gmail.com>.
It depends on the characters in your data. Converting the '<' to
'&lt;' is expected, but that's probably not what's causing your
problem. You might have characters in the document that can't be
properly escaped. If that's the case, you may not be able to send the
data as a string. Why not just send the XML data as XML data?

Anne

On 9/21/06, Satyajit Jha <sa...@gmail.com> wrote:
> Hi,
>
> I am using a stub client generated from wsdl using axis wsdl2java. I am
> trying to execute an operation with a string parameter. When I try to pass
> some XML data fragment as string for that parameter, it gives me "HTTP
> Transport error : '400' - 'Bad Request' " error. I looked at the SOAP
> request being generated. The '<' character in the XML string that I passed
> was modified into &lt;. Now this happens, I believe,  because the stub code
> is using XMLStreamWriter.writeCharacters() on the XML string which doesn't
> accept any such character in the string. Now I dont know how I should
> resolve this problem. Is there anyway in which I can pass an XML data as
> string parameter. I will appreciate any help.
>
> Regards,
> Satyajit
>

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