You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Timothy Waxland <ti...@gmail.com> on 2009/05/22 09:57:41 UTC

null values populated from non-null response

Hi

i'm having a problem processing a response from a web service call where my
objects end up with either null and/or have null properties. the raw
response is shown below:
---
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
   xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <SOAP-ENV:Header xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
       xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding
"></SOAP-ENV:Header>
   <SOAP-ENV:Body>
       <ser-root:captureDetailsResponse xmlns:ser-root="
http://domain.com/PAS">
           <CaptureDetailsResponse xmlns:ser-root="
http://domain.com/CaptureDetailsResponse">
               <ID>2121545</ID>
               <URN>78232150065</URN>
               <URL></URL>
           </CaptureDetailsResponse>
           <ServiceStatusCode xmlns:ser-root="
http://domain.com/haha:captureDetails">OK</ServiceStatusCode>
       </ser-root:captureDetailsResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
---

my resulting CaptureDetailsResponse is null and the status code is null too
both of which are returned within a non-null captureDetailsResponse object
(forgive confusing naming - not my idea)

i've trolled through docs, forums and w3c docs which helped greatly in my
understanding of how namespaces work but numerous combinations i have tried
on the client end still results in null values.

what does work is if the response was prefixed with the prefix defined for
that namespace as in:
<ser-root:CaptureDetailsResponse xmlns:ser-root="
http://domain.com/CaptureDetailsResponse"> ... etc

with the above, all is well but i can not impose that on the server (client
webmethods system). i fear i have missed something simple that is causing my
client components to not be populated with respective values. i also
understood from my reading that the above soap response is valid (dumb
naming aside) and that even though the prefix is not used, the fact that it
is declared is enough and it should also apply to child elements. from the
w3c recommendation i read: (http://www.w3.org/TR/REC-xml-names)

<x xmlns:edi='http://ecommerce.example.org/schema'>
 <!-- the "edi" prefix is bound to http://ecommerce.example.org/schema
      for the "x" element and contents -->
</x>

so in my similar case, even though x does not include the prefix, the
namespace prefixed by edi applies to x and all its contents. in my case,
which i believe is the same, it seems to fail. using soapUI (or even in my
own integration tests using a fake but running web service) the whole thing
works fine. but as an example the default response that soapUI generates
uses prefixes everywhere as does my fake web service. in any case, i believe
the response to be valid and something on the cxf end is misinterpreting or
not applying the namespace correctly.

suggestions appreciated, i'm really stumped.

thanks
Timothy

Re: null values populated from non-null response

Posted by Timothy Waxland <ti...@gmail.com>.
hi

yep, validation fails in soapUI too (i was looking at the popup menus in the
tree nodes not the editor - thanks for the tip)

an interceptor is what i was thinking too. i was really hoping to avoid it
but its starting to look like i won't be able to. i'm looking into that now
- fiddling with the incoming message is untidy work.

thanks heaps for your input on this.

Timothy.

On Sun, May 24, 2009 at 12:28 AM, Andrew Clegg <an...@nervechannel.com>wrote:

> 2009/5/23 Timothy Waxland <ti...@gmail.com>:
> > Hi
> >
> > thanks for responding.
> > i turned on validation on the client side and it through an exception
> where
> > i expected it to - so i'm pretty sure their response is not correct.  (i
> > couldn't find the validate option in soapUI)
>
> It's in the right mouse button menu if you click on the actual XML
> text of a request or response. But if CXF schema validation rejects
> it, that's a good enough sign :-)
>
> There may be some JAXB option that allows you to override namespaces,
> but I'm just guessing here. Failing that I guess you could write an
> interceptor to 'fix' the incoming message with an XSLT transformation
> (or other means) before JAXB unmarshalling takes place. Or write a
> Dispatch client that processes the raw XML without using databinding
> -- that way it wouldn't matter if the message didn't match the schema.
>
> Andrew.
>
> --
> :: http://biotext.org.uk/ ::
>

Re: null values populated from non-null response

Posted by Andrew Clegg <an...@nervechannel.com>.
2009/5/23 Timothy Waxland <ti...@gmail.com>:
> Hi
>
> thanks for responding.
> i turned on validation on the client side and it through an exception where
> i expected it to - so i'm pretty sure their response is not correct.  (i
> couldn't find the validate option in soapUI)

It's in the right mouse button menu if you click on the actual XML
text of a request or response. But if CXF schema validation rejects
it, that's a good enough sign :-)

There may be some JAXB option that allows you to override namespaces,
but I'm just guessing here. Failing that I guess you could write an
interceptor to 'fix' the incoming message with an XSLT transformation
(or other means) before JAXB unmarshalling takes place. Or write a
Dispatch client that processes the raw XML without using databinding
-- that way it wouldn't matter if the message didn't match the schema.

Andrew.

-- 
:: http://biotext.org.uk/ ::

Re: null values populated from non-null response

Posted by Timothy Waxland <ti...@gmail.com>.
Hi

thanks for responding.
i turned on validation on the client side and it through an exception where
i expected it to - so i'm pretty sure their response is not correct.  (i
couldn't find the validate option in soapUI)

as far as the interpretation of the w3c reference, i think you're quite
right and that makes more sense - also feeds into why their response is not
correct. and there is no default namespace defined in the response that i
can see.

the relevant portion of the wsdl is pasted below (the whole thing is rather
large). i have pasted the 'bad' response i'm getting again below this:

--- wsdl ---
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:dx5="
http://domain.com/VaPAS.flowSrvs:captureDetails/CaptureDetailsResponse"
    targetNamespace="
http://domain.com/VaPAS.flowSrvs:captureDetails/CaptureDetailsResponse">
    <xsd:element name="CaptureDetailsResponse"
type="dx5:CaptureDetailsResponse" />
    <xsd:complexType name="CaptureDetailsResponse">
        <xsd:sequence>
            <xsd:element name="SubjectID" nillable="true" type="xsd:string"
/>
            <xsd:element name="URN" nillable="true" type="xsd:string" />
            <xsd:element name="URL" nillable="true" type="xsd:string"
minOccurs="0" />
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:dx6="http://domain.com/VaPAS.flowSrvs:captureDetails"
    targetNamespace="http://domain.com/VaPAS.flowSrvs:captureDetails">
    <xsd:element name="ServiceStatusCode" type="xsd:string" />
    <xsd:element name="ServiceStatusDescription" type="xsd:string" />
</xsd:schema>
<xsd:complexType name="captureDetailsResponse">
    <xsd:sequence>
        <xsd:element ref="dx5:CaptureDetailsResponse" />
        <xsd:element ref="dx6:ServiceStatusCode" />
        <xsd:element ref="dx6:ServiceStatusDescription" minOccurs="0" />
    </xsd:sequence>
</xsd:complexType>
-------------------------------------------------------

--- response ---
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
    xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <SOAP-ENV:Header xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding"></SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <ser-root:captureDetailsResponse xmlns:ser-root="
http://domain.com/VaPAS/webConns/provider/PAS">
            <CaptureDetailsResponse xmlns:ser-root="
http://domain.com/VaPAS.flowSrvs:captureDetails/CaptureDetailsResponse">
                <SubjectID>767688091</SubjectID>
                <URN>774947201</URN>
                <URL></URL>
            </CaptureDetailsResponse>
            <ServiceStatusCode xmlns:ser-root="
http://domain.com/VaPAS.flowSrvs:captureDetails">GBL.OK</ServiceStatusCode>
        </ser-root:captureDetailsResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
-------------------------------------------

thanks
Timothy



On Fri, May 22, 2009 at 9:35 PM, Andrew Clegg <an...@nervechannel.com>wrote:

> 2009/5/22 Timothy Waxland <ti...@gmail.com>:
>
> > with the above, all is well but i can not impose that on the server
> (client
> > webmethods system). i fear i have missed something simple that is causing
> my
> > client components to not be populated with respective values. i also
> > understood from my reading that the above soap response is valid (dumb
> > naming aside) and that even though the prefix is not used, the fact that
> it
> > is declared is enough and it should also apply to child elements. from
> the
> > w3c recommendation i read: (http://www.w3.org/TR/REC-xml-names)
> >
> > <x xmlns:edi='http://ecommerce.example.org/schema'>
> >  <!-- the "edi" prefix is bound to http://ecommerce.example.org/schema
> >      for the "x" element and contents -->
> > </x>
> >
> > so in my similar case, even though x does not include the prefix, the
> > namespace prefixed by edi applies to x and all its contents.
>
> Unless I'm very much mistaken, the phrase 'the "edi" prefix is bound
> to http://ecommerce.example.org/schema for the "x" element and
> contents' doesn't mean 'the x element and all its children are in the
> http://ecommerce.example.org/schema namespace'. It means, I thought,
> 'anywhere you use the edi prefix in the x element or any of its
> children, it will be bound to http://ecommerce.example.org/schema'.
> But AFAIK unprefixed elements will still be in the default namespace.
>
> Apologies if that's what you meant and I'm misunderstanding...
>
> > in my case,
> > which i believe is the same, it seems to fail. using soapUI (or even in
> my
> > own integration tests using a fake but running web service) the whole
> thing
> > works fine. but as an example the default response that soapUI generates
> > uses prefixes everywhere as does my fake web service. in any case, i
> believe
> > the response to be valid and something on the cxf end is misinterpreting
> or
> > not applying the namespace correctly.
>
> Hard to tell much without your WSDL, but what happens when:
>
> (a) you right-click on the problematic message in soapUI and choose
> 'Validate'?
>
> (b) you turn on schema validation in CXF?
>
> Andrew.
>
>
>
> --
> :: http://biotext.org.uk/ ::
>

Re: null values populated from non-null response

Posted by Andrew Clegg <an...@nervechannel.com>.
2009/5/22 Timothy Waxland <ti...@gmail.com>:

> with the above, all is well but i can not impose that on the server (client
> webmethods system). i fear i have missed something simple that is causing my
> client components to not be populated with respective values. i also
> understood from my reading that the above soap response is valid (dumb
> naming aside) and that even though the prefix is not used, the fact that it
> is declared is enough and it should also apply to child elements. from the
> w3c recommendation i read: (http://www.w3.org/TR/REC-xml-names)
>
> <x xmlns:edi='http://ecommerce.example.org/schema'>
>  <!-- the "edi" prefix is bound to http://ecommerce.example.org/schema
>      for the "x" element and contents -->
> </x>
>
> so in my similar case, even though x does not include the prefix, the
> namespace prefixed by edi applies to x and all its contents.

Unless I'm very much mistaken, the phrase 'the "edi" prefix is bound
to http://ecommerce.example.org/schema for the "x" element and
contents' doesn't mean 'the x element and all its children are in the
http://ecommerce.example.org/schema namespace'. It means, I thought,
'anywhere you use the edi prefix in the x element or any of its
children, it will be bound to http://ecommerce.example.org/schema'.
But AFAIK unprefixed elements will still be in the default namespace.

Apologies if that's what you meant and I'm misunderstanding...

> in my case,
> which i believe is the same, it seems to fail. using soapUI (or even in my
> own integration tests using a fake but running web service) the whole thing
> works fine. but as an example the default response that soapUI generates
> uses prefixes everywhere as does my fake web service. in any case, i believe
> the response to be valid and something on the cxf end is misinterpreting or
> not applying the namespace correctly.

Hard to tell much without your WSDL, but what happens when:

(a) you right-click on the problematic message in soapUI and choose 'Validate'?

(b) you turn on schema validation in CXF?

Andrew.



-- 
:: http://biotext.org.uk/ ::