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 Duncan Doyle <du...@gmail.com> on 2006/01/10 17:05:36 UTC

Namespace and bean mappings in response??

Hello,

We are currently using Webmethods Glue 5 as our SOAP interface to our
Webservices (which are consumed by multiple .NET applications). We want
toget rid of Glue and switch to Axis.

We however have some problems. The .NET applications expect a certain format
of SOAP response (which is currently created by Glue) and we can't seem to
reproduce this SOAP response with Axis 1.3.

We have a Java Bean which contains the response. This Bean (called
ProductResponse) extends a Java Bean called FrameworkReponse (which contains
responses that are similar for all our webservices, for example error
responses). This FrameworkResponse bean contains 2 arrays of other
JavaBeans, namely Error and Message.

Now, when we get an error response (which is contained by our Error bean,
which in it's turn is contained by our FrameworkResponse bean) Glue returns
the following SOAP message:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
          xmlns:n1="
http://services.company.com/product/package/company.framework.w
ebservice.responsemodel /"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soap:Body>
       <n:getProductResponse xmlns:n="http://company.com/product">
           <n:Result>
               <errors>
                   <n1:Error>
                       <optionalDescription>Lookup
error</optionalDescription>
                       <errorText>Product lookup error</errorText>
                       <errorID xsi:nil="1"/>
                       <errorCode>501</errorCode>
                   </n1:Error>
               </errors>
               <messages xsi:nil="1"/>
               <product xsi:nil="1"/>
           </n:Result>
       </n:getProductResponse>
   </soap:Body>
</soap:Envelope>


The message that Axis generates on the same request looks like this:

<?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>
       <getProductResponse xmlns="http://company.com/product ">
           <Result>
               <errors>
                   <errors>
                       <errorCode>501</errorCode>
                       <errorID xsi:nil="true"/>
                       <errorText>Lookup error</foutText>
                       <optionalDescription>Product lookup
error</optionalDescription>
                   </errors>
               </errors>
               <messages xsi:nil="true"/>
               <product xsi:nil="true"/>
           </Result>
       </getProductResponse>
   </soapenv:Body>
</soapenv:Envelope>


As you can see, in the Glue response the <errors> tag encapsulates a <Error>
tag (which is the same name as our bean's classname and is in the namespace
"
http://services.company.com/product/package/company.framework.webservice.responsemodel"
. However, in the Axis response the <errors> tag encapsulates another
<errors> tag which is in the same namespace as our <getProductResponse>.

The <service> part of my wsdd looks like this:

<service name="ProductService" style="wrapped">
       <parameter name="className" value="comany.web.ProductServiceEndPoint
"/>
       <parameter name="allowedMethods" value="getProduct"/>
       <beanMapping qname="example:ProductKey" xmlns:example="
http://comapany.com/product" languageSpecificType="java:company.ProductKey"/>

       <beanMapping qname="exampleresp:Result" xmlns:exampleresp="
http://company.com/product" languageSpecificType="java:
company.web.response.ProductResponse"/>
       <beanMapping qname="respframework:Error" xmlns:respframework="
http://company.com/product/package/company.framework.webservice.responsemodel/"
languageSpecificType="java:company.webservice.responsemodel.Error"/>
       <beanMapping qname="respframework:Message" xmlns:respframework="
http://company.com/product/package/company.framework.webservice.responsemodel/"
languageSpecificType="java:
company.com.framework.webservice.responsemodel.Message"/>

       <operation name="getProduct" qname="nsname:getProduct" xmlns:nsname="
http://company.com/product"
                returnQName="nsname:Result">
           <parameter name="key"/>
       </operation>
</service>


As you can see, I have defined a bean mapping from my Error bean to an xml
entity with the qualified name: "respframework:Error" where "respframework"
is "
http://company.com/product/package/company.framework.webservice.reponsemodel/".
So why doesn't Axis use this namespace in the response but the namespace of
the getProductResult instead?? And why does Axis not map the Error bean to
an <Error> tag (the name of the bean) but to an <errors> tag???

Another question. I have specified the bean mapping of my ProductResponse
bean to an xml <Result> element. However, when I do this, the I get an xml
<getProductResponse> tag instead of a <Result> tag. I've solved this by
specifying this qname in the <operation>, but why do I have to do this? Why
doesn't Axis use the specified beanmapping in its reponse SOAP message??

With kind regards,

Duncan Doyle

Re: Namespace and bean mappings in response??

Posted by Duncan Doyle <Du...@gmail.com>.
Well, our .NET web-frontends depend on our current WSDL, they won't like 
it when I change it. Because Axis seems to discard my response 
bean-mappings from the WSDD, I tried to create the Java classes from our 
current WSDL with WSDL2Java. It gave me some helper classes which 
contain the correct mappings. However, when I try to run my application 
with these helper classes, my WebSphere (WAS 5.1) server starts 
complaining about classloader problems (this seems to be a known 
problem, I found a couple of posts on discussion forums regarding this 
issue).

So, as long as I can't define the correct mappings in my WSDD, Axis 
seems to be a "no go" for us. I really want to use Axis, so I hope that 
someone has a solution to my problems.

With kind regards,

Duncan Doyle


Anne Thomas Manes wrote:

> I suggest you start with your WSDL rather than your code.
>
> Anne
>
> On 1/10/06, *Duncan Doyle* <duncan.doyle@gmail.com 
> <ma...@gmail.com>> wrote:
>
>     Hello,
>
>     We are currently using Webmethods Glue 5 as our SOAP interface to
>     our Webservices (which are consumed by multiple .NET
>     applications). We want toget rid of Glue and switch to Axis.
>
>     We however have some problems. The .NET applications expect a
>     certain format of SOAP response (which is currently created by
>     Glue) and we can't seem to reproduce this SOAP response with Axis 1.3.
>
>     We have a Java Bean which contains the response. This Bean (called
>     ProductResponse) extends a Java Bean called FrameworkReponse
>     (which contains responses that are similar for all our
>     webservices, for example error responses). This FrameworkResponse
>     bean contains 2 arrays of other JavaBeans, namely Error and Message.
>
>     Now, when we get an error response (which is contained by our
>     Error bean, which in it's turn is contained by our
>     FrameworkResponse bean) Glue returns the following SOAP message:
>
>     <?xml version="1.0" encoding="UTF-8"?>
>     <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/ "
>               xmlns:n1="
>     http://services.company.com/product/package/company.framework.webservice.responsemodel
>     /"
>               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>        <soap:Body>
>            <n:getProductResponse xmlns:n="http://company.com/product">
>                <n:Result>
>                    <errors>
>                        <n1:Error>
>                            <optionalDescription>Lookup
>     error</optionalDescription>
>                            <errorText>Product lookup error</errorText>
>                            <errorID xsi:nil="1"/>
>                            <errorCode>501</errorCode>
>                        </n1:Error>
>                    </errors>
>                    <messages xsi:nil="1"/>
>                    <product xsi:nil="1"/>
>                </n:Result>
>            </n:getProductResponse>
>        </soap:Body>
>     </soap:Envelope>
>
>
>     The message that Axis generates on the same request looks like this:
>
>     <?xml version="1.0" encoding="UTF-8"?>
>     <soapenv:Envelope xmlns:soapenv="
>     http://schemas.xmlsoap.org/soap/envelope/"
>     <http://schemas.xmlsoap.org/soap/envelope/%22>
>              xmlns:xsd="http://www.w3.org/2001/XMLSchema "
>              xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
>     <http://www.w3.org/2001/XMLSchema-instance%22>>
>        <soapenv:Body>
>            <getProductResponse xmlns="http://company.com/product ">
>                <Result>
>                    <errors>
>                        <errors>
>                            <errorCode>501</errorCode>
>                            <errorID xsi:nil="true"/>
>                            <errorText>Lookup error</foutText>
>                            <optionalDescription>Product lookup
>     error</optionalDescription>
>                        </errors>
>                    </errors>
>                    <messages xsi:nil="true"/>
>                    <product xsi:nil="true"/>
>                </Result>
>            </getProductResponse>
>        </soapenv:Body>
>     </soapenv:Envelope>
>
>
>     As you can see, in the Glue response the <errors> tag encapsulates
>     a <Error> tag (which is the same name as our bean's classname and
>     is in the namespace "
>     http://services.company.com/product/package/company.framework.webservice.responsemodel
>     <http://services.company.com/product/package/company.framework.webservice.responsemodel>"
>     . However, in the Axis response the <errors> tag encapsulates
>     another <errors> tag which is in the same namespace as our
>     <getProductResponse>.
>
>     The <service> part of my wsdd looks like this:
>
>     <service name="ProductService" style="wrapped">
>            <parameter name="className"
>     value="comany.web.ProductServiceEndPoint "/>
>            <parameter name="allowedMethods" value="getProduct"/>
>            <beanMapping qname="example:ProductKey" xmlns:example="
>     http://comapany.com/product"
>     languageSpecificType="java:company.ProductKey"/>
>            <beanMapping qname="exampleresp:Result"
>     xmlns:exampleresp="http://company.com/product
>     <http://company.com/product>"
>     languageSpecificType="java:company.web.response.ProductResponse "/>
>            <beanMapping qname="respframework:Error"
>     xmlns:respframework="
>     http://company.com/product/package/company.framework.webservice.responsemodel/
>     <http://company.com/product/package/company.framework.webservice.responsemodel/>"
>     languageSpecificType="java:company.webservice.responsemodel.Error"/>
>            <beanMapping qname="respframework:Message"
>     xmlns:respframework="
>     http://company.com/product/package/company.framework.webservice.responsemodel/"
>     languageSpecificType="java:company.com.framework.webservice.responsemodel.Message"/>
>
>            <operation name="getProduct" qname="nsname:getProduct"
>     xmlns:nsname="http://company.com/product"
>                     returnQName="nsname:Result">
>                <parameter name="key"/>
>            </operation>
>     </service>
>
>
>     As you can see, I have defined a bean mapping from my Error bean
>     to an xml entity with the qualified name: "respframework:Error"
>     where "respframework" is
>     "http://company.com/product/package/company.framework.webservice.reponsemodel/
>     <http://company.com/product/package/company.framework.webservice.reponsemodel/>".
>     So why doesn't Axis use this namespace in the response but the
>     namespace of the getProductResult instead?? And why does Axis not
>     map the Error bean to an <Error> tag (the name of the bean) but to
>     an <errors> tag???
>
>     Another question. I have specified the bean mapping of my
>     ProductResponse bean to an xml <Result> element. However, when I
>     do this, the I get an xml <getProductResponse> tag instead of a
>     <Result> tag. I've solved this by specifying this qname in the
>     <operation>, but why do I have to do this? Why doesn't Axis use
>     the specified beanmapping in its reponse SOAP message??
>
>     With kind regards,
>
>     Duncan Doyle
>
>


Re: Namespace and bean mappings in response??

Posted by Anne Thomas Manes <at...@gmail.com>.
I suggest you start with your WSDL rather than your code.

Anne

On 1/10/06, Duncan Doyle <du...@gmail.com> wrote:
>
> Hello,
>
> We are currently using Webmethods Glue 5 as our SOAP interface to our
> Webservices (which are consumed by multiple .NET applications). We want
> toget rid of Glue and switch to Axis.
>
> We however have some problems. The .NET applications expect a certain
> format of SOAP response (which is currently created by Glue) and we can't
> seem to reproduce this SOAP response with Axis 1.3.
>
> We have a Java Bean which contains the response. This Bean (called
> ProductResponse) extends a Java Bean called FrameworkReponse (which contains
> responses that are similar for all our webservices, for example error
> responses). This FrameworkResponse bean contains 2 arrays of other
> JavaBeans, namely Error and Message.
>
> Now, when we get an error response (which is contained by our Error bean,
> which in it's turn is contained by our FrameworkResponse bean) Glue returns
> the following SOAP message:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
>           xmlns:n1="http://services.company.com/product/package/company.framework.w
> ebservice.responsemodel /"
>           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>    <soap:Body>
>        <n:getProductResponse xmlns:n="http://company.com/product">
>            <n:Result>
>                <errors>
>                    <n1:Error>
>                        <optionalDescription>Lookup
> error</optionalDescription>
>                        <errorText>Product lookup error</errorText>
>                        <errorID xsi:nil="1"/>
>                        <errorCode>501</errorCode>
>                    </n1:Error>
>                </errors>
>                <messages xsi:nil="1"/>
>                <product xsi:nil="1"/>
>            </n:Result>
>        </n:getProductResponse>
>    </soap:Body>
> </soap:Envelope>
>
>
> The message that Axis generates on the same request looks like this:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> <http://schemas.xmlsoap.org/soap/envelope/%22>
>          xmlns:xsd="http://www.w3.org/2001/XMLSchema "
>          xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"<http://www.w3.org/2001/XMLSchema-instance%22>
> >
>    <soapenv:Body>
>        <getProductResponse xmlns="http://company.com/product ">
>            <Result>
>                <errors>
>                    <errors>
>                        <errorCode>501</errorCode>
>                        <errorID xsi:nil="true"/>
>                        <errorText>Lookup error</foutText>
>                        <optionalDescription>Product lookup
> error</optionalDescription>
>                    </errors>
>                </errors>
>                <messages xsi:nil="true"/>
>                <product xsi:nil="true"/>
>            </Result>
>        </getProductResponse>
>    </soapenv:Body>
> </soapenv:Envelope>
>
>
> As you can see, in the Glue response the <errors> tag encapsulates a
> <Error> tag (which is the same name as our bean's classname and is in the
> namespace "
> http://services.company.com/product/package/company.framework.webservice.responsemodel"
> . However, in the Axis response the <errors> tag encapsulates another
> <errors> tag which is in the same namespace as our <getProductResponse>.
>
> The <service> part of my wsdd looks like this:
>
> <service name="ProductService" style="wrapped">
>        <parameter name="className" value="
> comany.web.ProductServiceEndPoint "/>
>        <parameter name="allowedMethods" value="getProduct"/>
>        <beanMapping qname="example:ProductKey" xmlns:example="http://comapany.com/product"
> languageSpecificType="java:company.ProductKey"/>
>        <beanMapping qname="exampleresp:Result" xmlns:exampleresp="
> http://company.com/product" languageSpecificType="java:
> company.web.response.ProductResponse "/>
>        <beanMapping qname="respframework:Error" xmlns:respframework="http://company.com/product/package/company.framework.webservice.responsemodel/
> " languageSpecificType="java:company.webservice.responsemodel.Error"/>
>        <beanMapping qname="respframework:Message" xmlns:respframework="http://company.com/product/package/company.framework.webservice.responsemodel/"
> languageSpecificType="java:
> company.com.framework.webservice.responsemodel.Message"/>
>
>        <operation name="getProduct" qname="nsname:getProduct"
> xmlns:nsname="http://company.com/product"
>                 returnQName="nsname:Result">
>            <parameter name="key"/>
>        </operation>
> </service>
>
>
> As you can see, I have defined a bean mapping from my Error bean to an xml
> entity with the qualified name: "respframework:Error" where "respframework"
> is "
> http://company.com/product/package/company.framework.webservice.reponsemodel/".
> So why doesn't Axis use this namespace in the response but the namespace of
> the getProductResult instead?? And why does Axis not map the Error bean to
> an <Error> tag (the name of the bean) but to an <errors> tag???
>
> Another question. I have specified the bean mapping of my ProductResponse
> bean to an xml <Result> element. However, when I do this, the I get an xml
> <getProductResponse> tag instead of a <Result> tag. I've solved this by
> specifying this qname in the <operation>, but why do I have to do this? Why
> doesn't Axis use the specified beanmapping in its reponse SOAP message??
>
> With kind regards,
>
> Duncan Doyle
>