You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Inmaculada Marín <in...@um.es> on 2010/10/13 13:11:42 UTC

Problems while processing a request in a web service

Hello all,

 

I am implementing a web service in CXF, but I have met some problems.

 

I have generated my web service from a WSDL. This WSDL  defines
document/literal style and operations with parameters according to the
following structure:

 

<xs:complexType name="AnyType">

        <xs:sequence>

            <xs:any maxOccurs="unbounded" minOccurs="0"/>

        </xs:sequence>

</xs:complexType>

 

 

Then, my web service is generated. Operation parameters are of Java type
AnyType which content is 

    @XmlAnyElement(lax = true)

    protected List<org.w3c.dom.Element> any;

 

The problems is that, when I try to get operation parameters as a Dom
element I found that:

1.       I can’t find the root element.

2.       Some content are re-formatted, so I have problems when dealing it.

 

Next, I try to illustrate the problem. When I invoke my web service, I
intercept the soap message, and I can see the following:

 

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><dss:Sig
nRequest Profile="urn:umu:eadmin:services:sign:profiles:simpleSign"
RequestID="0001" xmlns:dss="urn:oasis:names:tc:dss:1.0:core:schema"
xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"><dss:OptionalInputs><dss:
ClaimedIdentity><dss:Name>155.54.210.72/aplicacion de
prueba</dss:Name></dss:ClaimedIdentity><dss:SignatureType>urn:ietf:rfc:3275<
/dss:SignatureType><dss:AddTimestamp
Type="urn:ietf:rfc:3161"/><dss:Properties><dss:SignedProperties><dss:Propert
y><dss:Identifier>urn:oasis:names:tc:dss:1.0:core:schema:TimeStampTime</dss:
Identifier></dss:Property></dss:SignedProperties></dss:Properties></dss:Opti
onalInputs><dss:InputDocuments><dss:Document ID="ID00001"
RefURI="ID00001"><dss:InlineXML><root>

 

    <regla-ipsec>

 

        <dir-origen>155.54.0.0</dir-origen>

        <mascara-origen>255.255.0.0</mascara-origen>

        <dir-destino>81.65.45.3</dir-destino>

 

        <mascara-destino>255.255.255.255</mascara-destino>

        <puerto-origen>any</puerto-origen>

        <puerto-destino>80</puerto-destino>

        <protocolo>tcp</protocolo>

        <accion>autenticacion</accion>

        <modo>transporte</modo>

        <algoritmo-cifrado>3DES</algoritmo-cifrado>

        <algoritmo-firma>HMAC_WITH_MD5</algoritmo-firma>

    </regla-ipsec>

</root></dss:InlineXML></dss:Document></dss:InputDocuments></dss:SignRequest
></soapenv:Body></soapenv:Envelope>

 

As you can see, the SOAP body contains a root element, called
<dss:SignRequest>, which should be processed within the service
implementation.

 

However, within the service implementation, when I receive
List<org.w3c.dom.Element> and I try to reconstruct the soap body content as
a DOM element, I find that <dss:SignRequest> is missing and the content of
element <dss:InlineXML> has been re-formatted (missing: tabs, linefeeds,
etc.), as it is shown next:

 

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

<rootElement><dss:OptionalInputs

        xmlns:dss="urn:oasis:names:tc:dss:1.0:core:schema"

 
xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"><dss:ClaimedIdentity><dss
:Name>155.54.210.72/aplicacion de
prueba</dss:Name></dss:ClaimedIdentity><dss:SignatureType>urn:ietf:rfc:3275<
/dss:SignatureType><dss:AddTimestamp

 
Type="urn:ietf:rfc:3161"/><dss:Properties><dss:SignedProperties><dss:Propert
y><dss:Identifier>urn:oasis:names:tc:dss:1.0:core:schema:TimeStampTime</dss:
Identifier></dss:Property></dss:SignedProperties></dss:Properties></dss:Opti
onalInputs><dss:InputDocuments

        xmlns:dss="urn:oasis:names:tc:dss:1.0:core:schema"

            xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"><dss:Document

            ID="ID00001"
RefURI="ID00001"><dss:InlineXML><root><regla-ipsec><dir-origen>155.54.0.0</d
ir-origen><mascara-origen>255.255.0.0</mascara-origen><dir-destino>81.65.45.
3</dir-destino><mascara-destino>255.255.255.255</mascara-destino><puerto-ori
gen>any</puerto-origen><puerto-destino>80</puerto-destino><protocolo>tcp</pr
otocolo><accion>autenticacion</accion><modo>transporte</modo><algoritmo-cifr
ado>3DES</algoritmo-cifrado><algoritmo-firma>HMAC_WITH_MD5</algoritmo-firma>

    </regla-ipsec>

</root></dss:InlineXML></dss:Document></dss:InputDocuments></rootElement>

 

(In order to reconstruct the soap body content from
List<org.w3c.dom.Element>, I have created a new org.w3c.dom.Document, with a
root element called <rootElement>, where to append as child node de contents
of List<org.w3c.dom.Element>).

 

So I meet two problems: on the one side, I loose some information because
the element <dss:SignRequest> is missing, so I am not able to process the
request.

On the other hand, as the content of the element <dss:InlineXML> is
reformatted, when I deal that content, I obtain bad results, as I have to
apply cryptographic operations over it, so I need it the same
format/structure as it was send by the client (and you can see in the
intercepted soap message).

 

As a conclusion, I need to:

1.       Get the complete soap content body  (including the first element
<dss:SignRequest>) within the service implementation.

2.       Get the complete soap content body with the same format as it was
sent.

 

¿Could you be so kind as to help me, please?

 

Thank you very much in advance.

 

Regards,

Inma.

 

 


Re: Problems while processing a request in a web service

Posted by Peter Mihalik <pe...@gmail.com>.
Hi

2010/10/13 Inmaculada Marín <in...@um.es>

> Hello all,
>
>
>
> I am implementing a web service in CXF, but I have met some problems.
>
>
>
> I have generated my web service from a WSDL. This WSDL  defines
> document/literal style and operations with parameters according to the
> following structure:
>
>
>
> <xs:complexType name="AnyType">
>
>        <xs:sequence>
>
>            <xs:any maxOccurs="unbounded" minOccurs="0"/>
>
>        </xs:sequence>
>
> </xs:complexType>
>
>
>
>
>
> Then, my web service is generated. Operation parameters are of Java type
> AnyType which content is
>
>    @XmlAnyElement(lax = true)
>
>    protected List<org.w3c.dom.Element> any;
>
>
>
> The problems is that, when I try to get operation parameters as a Dom
> element I found that:
>
> 1.       I can’t find the root element.
>
> 2.       Some content are re-formatted, so I have problems when dealing it.
>
>
>
> Next, I try to illustrate the problem. When I invoke my web service, I
> intercept the soap message, and I can see the following:
>
>
>
> <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
> "><soapenv:Body><dss:Sig
> nRequest Profile="urn:umu:eadmin:services:sign:profiles:simpleSign"
> RequestID="0001" xmlns:dss="urn:oasis:names:tc:dss:1.0:core:schema"
>
> xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"><dss:OptionalInputs><dss:
> ClaimedIdentity><dss:Name>155.54.210.72/aplicacion de
>
> prueba</dss:Name></dss:ClaimedIdentity><dss:SignatureType>urn:ietf:rfc:3275<
> /dss:SignatureType><dss:AddTimestamp
>
> Type="urn:ietf:rfc:3161"/><dss:Properties><dss:SignedProperties><dss:Propert
>
> y><dss:Identifier>urn:oasis:names:tc:dss:1.0:core:schema:TimeStampTime</dss:
>
> Identifier></dss:Property></dss:SignedProperties></dss:Properties></dss:Opti
> onalInputs><dss:InputDocuments><dss:Document ID="ID00001"
> RefURI="ID00001"><dss:InlineXML><root>
>
>
>
>    <regla-ipsec>
>
>
>
>        <dir-origen>155.54.0.0</dir-origen>
>
>        <mascara-origen>255.255.0.0</mascara-origen>
>
>        <dir-destino>81.65.45.3</dir-destino>
>
>
>
>        <mascara-destino>255.255.255.255</mascara-destino>
>
>        <puerto-origen>any</puerto-origen>
>
>        <puerto-destino>80</puerto-destino>
>
>        <protocolo>tcp</protocolo>
>
>        <accion>autenticacion</accion>
>
>        <modo>transporte</modo>
>
>        <algoritmo-cifrado>3DES</algoritmo-cifrado>
>
>        <algoritmo-firma>HMAC_WITH_MD5</algoritmo-firma>
>
>    </regla-ipsec>
>
>
> </root></dss:InlineXML></dss:Document></dss:InputDocuments></dss:SignRequest
> ></soapenv:Body></soapenv:Envelope>
>
>
>
> As you can see, the SOAP body contains a root element, called
> <dss:SignRequest>, which should be processed within the service
> implementation.
>
>
>
> However, within the service implementation, when I receive
> List<org.w3c.dom.Element> and I try to reconstruct the soap body content as
> a DOM element, I find that <dss:SignRequest> is missing and the content of
> element <dss:InlineXML> has been re-formatted (missing: tabs, linefeeds,
> etc.), as it is shown next:
>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <rootElement><dss:OptionalInputs
>
>        xmlns:dss="urn:oasis:names:tc:dss:1.0:core:schema"
>
>
>
> xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"><dss:ClaimedIdentity><dss
> :Name>155.54.210.72/aplicacion de
>
> prueba</dss:Name></dss:ClaimedIdentity><dss:SignatureType>urn:ietf:rfc:3275<
> /dss:SignatureType><dss:AddTimestamp
>
>
>
> Type="urn:ietf:rfc:3161"/><dss:Properties><dss:SignedProperties><dss:Propert
>
> y><dss:Identifier>urn:oasis:names:tc:dss:1.0:core:schema:TimeStampTime</dss:
>
> Identifier></dss:Property></dss:SignedProperties></dss:Properties></dss:Opti
> onalInputs><dss:InputDocuments
>
>        xmlns:dss="urn:oasis:names:tc:dss:1.0:core:schema"
>
>            xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"><dss:Document
>
>            ID="ID00001"
>
> RefURI="ID00001"><dss:InlineXML><root><regla-ipsec><dir-origen>155.54.0.0</d
>
> ir-origen><mascara-origen>255.255.0.0</mascara-origen><dir-destino>81.65.45.
>
> 3</dir-destino><mascara-destino>255.255.255.255</mascara-destino><puerto-ori
>
> gen>any</puerto-origen><puerto-destino>80</puerto-destino><protocolo>tcp</pr
>
> otocolo><accion>autenticacion</accion><modo>transporte</modo><algoritmo-cifr
>
> ado>3DES</algoritmo-cifrado><algoritmo-firma>HMAC_WITH_MD5</algoritmo-firma>
>
>    </regla-ipsec>
>
> </root></dss:InlineXML></dss:Document></dss:InputDocuments></rootElement>
>
>
>
> (In order to reconstruct the soap body content from
> List<org.w3c.dom.Element>, I have created a new org.w3c.dom.Document, with
> a
> root element called <rootElement>, where to append as child node de
> contents
> of List<org.w3c.dom.Element>).
>
>
>
> So I meet two problems: on the one side, I loose some information because
> the element <dss:SignRequest> is missing, so I am not able to process the
> request.
>
> On the other hand, as the content of the element <dss:InlineXML> is
> reformatted, when I deal that content, I obtain bad results, as I have to
> apply cryptographic operations over it, so I need it the same
> format/structure as it was send by the client (and you can see in the
> intercepted soap message).
>
>
>
> As a conclusion, I need to:
>
> 1.       Get the complete soap content body  (including the first element
> <dss:SignRequest>) within the service implementation.
>

Try using the JAX-WS provider API if you need access to the whole soap
message / payload.
http://cxf.apache.org/docs/provider-services.html


>
> 2.       Get the complete soap content body with the same format as it was
> sent.
>

If you need to preserve the XML format including formatting (all the spaces
and tabs), then you need to send the data as CDATA or better base64Binary
(this will also preserve the original linefeeds used).


>
>
>
> ¿Could you be so kind as to help me, please?
>
>
>
> Thank you very much in advance.
>
>
>
> Regards,
>
> Inma.
>
>
>
>
>
>
--
Peter