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 Christian Ribeaud <ch...@finebrain.com> on 2007/05/26 13:35:16 UTC

XML stream to java Object

Hi,

If my XML stream response looks as following:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Server</faultcode>
      <faultstring>Invalid application client.</faultstring>
      <detail>
        <InvalidAuthenticationException xmlns="urn:SecurityServer">
          <cause xmlns:ns1="http://www.w3.org/2001/XMLSchema-instance"
ns1:nil="true"
            xmlns="http://exception.com" />
          <messages xmlns="http://exception.com">
            <string>Invalid application client.</string>
          </messages>
          <throwableCount xmlns="http://exception.com">1</throwableCount>
          <throwables xmlns="http://exception.com">
            <ns1:Throwable xmlns:ns1="http://lang.java" />
          </throwables>
        </InvalidAuthenticationException>
      </detail>
    </soap:Fault>
  </soap:Body>
</soap:Envelope>

How can I convert it into a java Object with Axis2? Doing it as following is
the correct way or am I completely wrong?

XMLStreamReader reader
XMLInputFactory.newInstance().createXMLStreamReader(new
StringReader(response));
OMElement element = new StAXOMBuilder(reader).getDocumentElement();

BeanUtil.deserialize(element, new Object[] {Fault.class}, new
DefaultObjectSupplier());

Any help would be gratefully appreciated. Thanks a lot and have a nice day.
Cheers,

christian



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


Re: XML stream to java Object

Posted by Davanum Srinivas <da...@gmail.com>.
christian,

Was the InvalidAuthenticationException class generated using
wsdl2java? BeanUtil.deserialize is usually just for pojo's.

thanks,
dims

On 5/26/07, Christian Ribeaud <ch...@finebrain.com> wrote:
> Hi,
>
> If my XML stream response looks as following:
>
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>   <soap:Body>
>     <soap:Fault>
>       <faultcode>soap:Server</faultcode>
>       <faultstring>Invalid application client.</faultstring>
>       <detail>
>         <InvalidAuthenticationException xmlns="urn:SecurityServer">
>           <cause xmlns:ns1="http://www.w3.org/2001/XMLSchema-instance"
> ns1:nil="true"
>             xmlns="http://exception.com" />
>           <messages xmlns="http://exception.com">
>             <string>Invalid application client.</string>
>           </messages>
>           <throwableCount xmlns="http://exception.com">1</throwableCount>
>           <throwables xmlns="http://exception.com">
>             <ns1:Throwable xmlns:ns1="http://lang.java" />
>           </throwables>
>         </InvalidAuthenticationException>
>       </detail>
>     </soap:Fault>
>   </soap:Body>
> </soap:Envelope>
>
> How can I convert it into a java Object with Axis2? Doing it as following is
> the correct way or am I completely wrong?
>
> XMLStreamReader reader
> XMLInputFactory.newInstance().createXMLStreamReader(new
> StringReader(response));
> OMElement element = new StAXOMBuilder(reader).getDocumentElement();
>
> BeanUtil.deserialize(element, new Object[] {Fault.class}, new
> DefaultObjectSupplier());
>
> Any help would be gratefully appreciated. Thanks a lot and have a nice day.
> Cheers,
>
> christian
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>


-- 
Davanum Srinivas :: http://davanum.wordpress.com

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