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 Sagi Mann <sa...@gmail.com> on 2008/09/30 11:19:51 UTC

AxisFault when using jibx

Hello,
I've got an issue when working with a jibx axis2 client, based on the
tutorial at:
http://ws.apache.org/axis2/1_4_1/userguide-creatingclients-jibx.html
http://ws.apache.org/axis2/1_4_1/userguide-creatingclients-jibx.html 

I'd appreciate if someone could tell if this is a bug or a misuse.
thanks...


My web service is a JAXWS web service, that look like this:

@WebService
public class Hello {
    
    @WebMethod
    public String testOneArg(@WebParam(mode=Mode.IN, name="testOneArg0")
String name) {
        return "Hello " + name;
    }
}

I can correctly invoke the method when using axis2 client with ADB. But I
cannot invoke when using jibx. I get an execption:

org.apache.axis2.AxisFault: Expected "{http://ws/}testOneArgResponse" end
tag, found "return" start tag (line -1, col -1, in SOAP-message)
        at
samples.quickstart.service.adb.HelloServiceStub.fromOM(HelloServiceStub.java:641)
        at
samples.quickstart.service.adb.HelloServiceStub.testOneArg(HelloServiceStub.java:215)
        at
samples.quickstart.clients.ADBClient.testOneArg(ADBClient.java:57)
        at samples.quickstart.clients.ADBClient.main(ADBClient.java:43)

The xsd that JAXWS generates contains:

    <xs:complexType name="testOneArg">
        <xs:sequence>
            <xs:element name="testOneArg0" type="xs:string"
minOccurs="0"></xs:element>
        </xs:sequence>
    </xs:complexType>
    
    <xs:complexType name="testOneArgResponse">
        <xs:sequence>
            <xs:element name="return" type="xs:string"
minOccurs="0"></xs:element>
        </xs:sequence>
    </xs:complexType>

I use this schema when creating binding.xml with the xsd2jibx utility. The
binding.xml file contains:

  <mapping name="testOneArg" class="ws.TestOneArg">
    <namespace uri="http://ws/" default="elements"/>
    <value name="testOneArg0" field="testOneArg0" usage="optional"/>
  </mapping>
  <mapping name="testOneArgResponse" class="ws.TestOneArgResponse">
    <namespace uri="http://ws/" default="elements"/>
    <value name="return" field="_return" usage="optional"/>
  </mapping>


-- 
View this message in context: http://www.nabble.com/AxisFault-when-using-jibx-tp19738701p19738701.html
Sent from the Axis - User mailing list archive at Nabble.com.


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


Re: AxisFault when using jibx

Posted by Sagi Mann <sa...@gmail.com>.
Found a way to solve one part of the problem: explicitly set the namespace
for the return value:

    @WebMethod 
    @WebResult(targetNamespace="http://ws/")
    public String testOneArg(@WebParam(mode=Mode.IN, name="testOneArg0")
String name) { 
        return "Hello " + name; 
    } 

This added a 'qualified' keyword to the schema:

    <xs:complexType name="testOneArgResponse"> 
        <xs:sequence> 
            <xs:element name="return" type="xs:string" form="qualified"
minOccurs="0"></xs:element> 
        </xs:sequence> 
    </xs:complexType> 

Now, I don't get the exception any more, but the input parameter always
comes in as null. I know this by writing a debug message at the service
side. The client code is:

    public static void testOneArg(HelloServiceStub stub){
        try{
            ws.TestOneArg arg = new ws.TestOneArg();
            arg.setTestOneArg0("john"); 
            ws.TestOneArgResponse res = stub.testOneArg(arg);
// expected output is "Hello john" but I get "Hello null":
            System.out.println(res.getReturn());
        } catch(Exception e){
            e.printStackTrace();
            System.err.println("\n\n\n");
        }
    }

Any ideas? thanks...

-- 
View this message in context: http://www.nabble.com/AxisFault-when-using-jibx-tp19738701p19739246.html
Sent from the Axis - User mailing list archive at Nabble.com.


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


Re: AxisFault when using jibx

Posted by Sagi Mann <sa...@gmail.com>.
I have an update: unfortunately, the solution with the targetNamespace on
each param only worked for me if the param is simple, i.e. String. However,
when my param was a bean, the issue continued in a different variation: the
bean was non-null, but all its properties were null.

Example:

I have a bean called ConcreteBean with a single 'name' property.

The following SOAP message is ok and the bean name is passed correctly to
the web service. Note the 'ws' namespace declared at the envelope:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ws="http://ws/">
   <soapenv:Header/>
   <soapenv:Body>
      <ws:testConcreteBeanArg>
         <ws:testConcreteBeanArg0>
            <name>my bean name</name>
         </ws:testConcreteBeanArg0>
      </ws:testConcreteBeanArg>
   </soapenv:Body>
</soapenv:Envelope>

The following SOAP message was generated by axis2/jibx, and does not work.
The service gets a non-null bean instance, but with a null name property.
Note the lack of 'ws:' prefix in the SOAP body and the lack of a 'ws'
namespace declaration:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <testConcreteBeanArg xmlns="http://ws/">
         <testConcreteBeanArg0>
            <name>my bean name</name>
         </testConcreteBeanArg0>
      </testConcreteBeanArg>
   </soapenv:Body>
</soapenv:Envelope>

pls advise... thanks.

-- 
View this message in context: http://www.nabble.com/AxisFault-when-using-jibx-tp19738701p19740500.html
Sent from the Axis - User mailing list archive at Nabble.com.


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


Re: AxisFault when using jibx

Posted by Sagi Mann <sa...@gmail.com>.
No problem. BTW, in the meantime, I switched to using jaxbri binding instead
of jibx.

The full web service code before all the additions of targetNamespace
annotation attributes is:

@WebService(
@XmlSeeAlso(SubBean.class)
public class Hello {
    
    @WebMethod
    public String testOneArg(@WebParam String name) { return "Hello " +
name; }
    
    @WebMethod
    public String testConcreteBeanArg(@WebParam ConcreteBean bean) {
        return "concrete bean: " + bean.getClass().getName() + " " +
bean.toString() +
                "[" +
                " name=" + bean.getName() +
                "]";
    }
    
    @WebMethod
    public String testAbstractBeanArg(@WebParam AbstractBean bean) {
        return "abstract bean: " + bean.getClass().getName() + " " +
bean.toString();
    }
    
    @WebMethod
    public String testException(@WebParam AbstractBean bean) throws
BeanException {
        if (bean.getColor().equals("black")) throw new BeanException("Black
exception");
        return "abstract bean: " + bean.getClass().getName() + " " +
bean.toString();
    }
}



The resulting full schema as generated by JAXW 2.1 over GlassFish v2
runtime, built with NetBeans 5.5.1 is:


<?xml version="1.0" encoding="UTF-8"?><!-- Published by JAX-WS RI at
http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.2-hudson-182-RC1.
--><xs:schema xmlns:tns="http://ws/"
xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0"
targetNamespace="http://ws/">
    
    <xs:element name="BeanException" type="tns:BeanException"></xs:element>
    
    <xs:element name="testAbstractBeanArg"
type="tns:testAbstractBeanArg"></xs:element>
    
    <xs:element name="testAbstractBeanArgResponse"
type="tns:testAbstractBeanArgResponse"></xs:element>
    
    <xs:element name="testConcreteBeanArg"
type="tns:testConcreteBeanArg"></xs:element>
    
    <xs:element name="testConcreteBeanArgResponse"
type="tns:testConcreteBeanArgResponse"></xs:element>
    
    <xs:element name="testException" type="tns:testException"></xs:element>
    
    <xs:element name="testExceptionResponse"
type="tns:testExceptionResponse"></xs:element>
    
    <xs:element name="testOneArg" type="tns:testOneArg"></xs:element>
    
    <xs:element name="testOneArgResponse"
type="tns:testOneArgResponse"></xs:element>
    
    <xs:complexType name="subBean">
        <xs:complexContent>
            <xs:extension base="tns:abstractBean">
                <xs:sequence>
                    <xs:element name="desc" type="xs:string"
minOccurs="0"></xs:element>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    
    <xs:complexType name="abstractBean" abstract="true">
        <xs:sequence>
            <xs:element name="color" type="xs:string"
minOccurs="0"></xs:element>
        </xs:sequence>
    </xs:complexType>
    
    <xs:complexType name="testConcreteBeanArg">
        <xs:sequence>
            <xs:element name="arg0" type="tns:concreteBean"
minOccurs="0"></xs:element>
        </xs:sequence>
    </xs:complexType>
    
    <xs:complexType name="concreteBean">
        <xs:sequence>
            <xs:element name="name" type="xs:string"
minOccurs="0"></xs:element>
        </xs:sequence>
    </xs:complexType>
    
    <xs:complexType name="testConcreteBeanArgResponse">
        <xs:sequence>
            <xs:element name="return" type="xs:string"
minOccurs="0"></xs:element>
        </xs:sequence>
    </xs:complexType>
    
    <xs:complexType name="testAbstractBeanArg">
        <xs:sequence>
            <xs:element name="arg0" type="tns:abstractBean"
minOccurs="0"></xs:element>
        </xs:sequence>
    </xs:complexType>
    
    <xs:complexType name="testAbstractBeanArgResponse">
        <xs:sequence>
            <xs:element name="return" type="xs:string"
minOccurs="0"></xs:element>
        </xs:sequence>
    </xs:complexType>
    
    <xs:complexType name="testException">
        <xs:sequence>
            <xs:element name="arg0" type="tns:abstractBean"
minOccurs="0"></xs:element>
        </xs:sequence>
    </xs:complexType>
    
    <xs:complexType name="testExceptionResponse">
        <xs:sequence>
            <xs:element name="return" type="xs:string"
minOccurs="0"></xs:element>
        </xs:sequence>
    </xs:complexType>
    
    <xs:complexType name="BeanException">
        <xs:sequence>
            <xs:element name="message" type="xs:string"
minOccurs="0"></xs:element>
        </xs:sequence>
    </xs:complexType>
    
    <xs:complexType name="testOneArg">
        <xs:sequence>
            <xs:element name="arg0" type="xs:string"
minOccurs="0"></xs:element>
        </xs:sequence>
    </xs:complexType>
    
    <xs:complexType name="testOneArgResponse">
        <xs:sequence>
            <xs:element name="return" type="xs:string"
minOccurs="0"></xs:element>
        </xs:sequence>
    </xs:complexType>
</xs:schema>

Hope this helps...

-- 
View this message in context: http://www.nabble.com/AxisFault-when-using-jibx-tp19738701p19747689.html
Sent from the Axis - User mailing list archive at Nabble.com.


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


Re: AxisFault when using jibx

Posted by Dennis Sosnoski <dm...@sosnoski.com>.
Looks like the JiBX code for Wsdl2Java may be having a problem with the 
schema generated by the JAXWS service. Can you provide the full schema 
portion of the WSDL, so that I can see the namespace usage?

By default, JAXB does not use elementFormDefault="qualified" in schema 
definitions, meaning only the top-level element definitions are 
namespace qualified. That's a shame, since 
elementFormDefault="qualified" is basically a best practice for clean 
XML structure. Wsdl2Java and JiBX should be able to handle it either 
way, though.

Thanks, and I'll look into the problem.

  - Dennis

-- 
Dennis M. Sosnoski
SOA and Web Services in Java
Axis2 Training and Consulting
http://www.sosnoski.com - http://www.sosnoski.co.nz
Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117



Sagi Mann wrote:
> Yes, this is misunderstanding, I simply used the sample quick start code tree
> as a template. This is why you see the .adb package, but I assure you it's
> jibx.
>
>
> DSosnoski wrote:
>   
>> Hi Sagi,
>>
>>  From your exception stack trace, it appears that you're still using 
>> ADB, rather than JiBX:
>>
>>     
>
> Anyway, I took your advice regarding TCPmon and found a difference between
> what SoapUI generates and what Axis2/JIbx generates:
>
> SoapUI sends the following request, which works great:
>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:ws="http://ws/">
>    <soapenv:Body>
>       <ws:testOneArg>
>          <testOneArg0>sagi</testOneArg0>
>       </ws:testOneArg>
>    </soapenv:Body>
> </soapenv:Envelope>
>
> Axis2/jibx sends:
>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
>    <soapenv:Body>
>       <testOneArg xmlns="http://ws/"> 
>          <testOneArg0>sagi</testOneArg0>
>       </testOneArg>
>    </soapenv:Body>
> </soapenv:Envelope>
>
> I found a solution, but it seems somewhat strange: not on the client side,
> but on the server side:
>
> If I added a targetNamespace to the method params as well, the SAME "bad"
> request now gets invoked correctly, i.e. when changing the web service like
> so:
>
>     @WebMethod
>     @WebResult(targetNamespace="http://ws/")
>     public String testOneArg(@WebParam(name="testOneArg0",
> targetNamespace="http://ws/") String name) {
>         return "Hello " + name;
>     }
>
> The Axis2/jibx client works great, and the same request it sent before now
> gets a proper "Hello john" response...
>
> I'm not sure if this is the "correct" solution, but at least it works. The
> con of this solution, is, of course, the fact that I need to "enforce"
> things on the service side, which may be 3rd party and out of my control. Is
> there any better way to do this?
>
> thanks
>   

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


Re: AxisFault when using jibx

Posted by Sagi Mann <sa...@gmail.com>.
Yes, this is misunderstanding, I simply used the sample quick start code tree
as a template. This is why you see the .adb package, but I assure you it's
jibx.


DSosnoski wrote:
> 
> Hi Sagi,
> 
>  From your exception stack trace, it appears that you're still using 
> ADB, rather than JiBX:
> 

Anyway, I took your advice regarding TCPmon and found a difference between
what SoapUI generates and what Axis2/JIbx generates:

SoapUI sends the following request, which works great:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ws="http://ws/">
   <soapenv:Body>
      <ws:testOneArg>
         <testOneArg0>sagi</testOneArg0>
      </ws:testOneArg>
   </soapenv:Body>
</soapenv:Envelope>

Axis2/jibx sends:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <testOneArg xmlns="http://ws/"> 
         <testOneArg0>sagi</testOneArg0>
      </testOneArg>
   </soapenv:Body>
</soapenv:Envelope>

I found a solution, but it seems somewhat strange: not on the client side,
but on the server side:

If I added a targetNamespace to the method params as well, the SAME "bad"
request now gets invoked correctly, i.e. when changing the web service like
so:

    @WebMethod
    @WebResult(targetNamespace="http://ws/")
    public String testOneArg(@WebParam(name="testOneArg0",
targetNamespace="http://ws/") String name) {
        return "Hello " + name;
    }

The Axis2/jibx client works great, and the same request it sent before now
gets a proper "Hello john" response...

I'm not sure if this is the "correct" solution, but at least it works. The
con of this solution, is, of course, the fact that I need to "enforce"
things on the service side, which may be 3rd party and out of my control. Is
there any better way to do this?

thanks
-- 
View this message in context: http://www.nabble.com/AxisFault-when-using-jibx-tp19738701p19739691.html
Sent from the Axis - User mailing list archive at Nabble.com.


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


Re: AxisFault when using jibx

Posted by Dennis Sosnoski <dm...@sosnoski.com>.
Hi Sagi,

 From your exception stack trace, it appears that you're still using 
ADB, rather than JiBX:

samples.quickstart.service.adb.HelloServiceStub.fromOM(HelloServiceStub.java:641)
        at
samples.quickstart.service.adb.HelloServiceStub.testOneArg(HelloServiceStub.java:215)
        at
samples.quickstart.clients.ADBClient.testOneArg(ADBClient.java:57)
        at samples.quickstart.clients.ADBClient.main(ADBClient.java:43)

Am I misunderstanding this? If so, it'd help if you can capture the 
response message with TCPMon so we can see what's actually there.

  - Dennis

-- 
Dennis M. Sosnoski
SOA and Web Services in Java
Axis2 Training and Consulting
http://www.sosnoski.com - http://www.sosnoski.co.nz
Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117


Sagi Mann wrote:
> Hello,
> I've got an issue when working with a jibx axis2 client, based on the
> tutorial at:
> http://ws.apache.org/axis2/1_4_1/userguide-creatingclients-jibx.html
> http://ws.apache.org/axis2/1_4_1/userguide-creatingclients-jibx.html 
>
> I'd appreciate if someone could tell if this is a bug or a misuse.
> thanks...
>
>
> My web service is a JAXWS web service, that look like this:
>
> @WebService
> public class Hello {
>     
>     @WebMethod
>     public String testOneArg(@WebParam(mode=Mode.IN, name="testOneArg0")
> String name) {
>         return "Hello " + name;
>     }
> }
>
> I can correctly invoke the method when using axis2 client with ADB. But I
> cannot invoke when using jibx. I get an execption:
>
> org.apache.axis2.AxisFault: Expected "{http://ws/}testOneArgResponse" end
> tag, found "return" start tag (line -1, col -1, in SOAP-message)
>         at
> samples.quickstart.service.adb.HelloServiceStub.fromOM(HelloServiceStub.java:641)
>         at
> samples.quickstart.service.adb.HelloServiceStub.testOneArg(HelloServiceStub.java:215)
>         at
> samples.quickstart.clients.ADBClient.testOneArg(ADBClient.java:57)
>         at samples.quickstart.clients.ADBClient.main(ADBClient.java:43)
>
> The xsd that JAXWS generates contains:
>
>     <xs:complexType name="testOneArg">
>         <xs:sequence>
>             <xs:element name="testOneArg0" type="xs:string"
> minOccurs="0"></xs:element>
>         </xs:sequence>
>     </xs:complexType>
>     
>     <xs:complexType name="testOneArgResponse">
>         <xs:sequence>
>             <xs:element name="return" type="xs:string"
> minOccurs="0"></xs:element>
>         </xs:sequence>
>     </xs:complexType>
>
> I use this schema when creating binding.xml with the xsd2jibx utility. The
> binding.xml file contains:
>
>   <mapping name="testOneArg" class="ws.TestOneArg">
>     <namespace uri="http://ws/" default="elements"/>
>     <value name="testOneArg0" field="testOneArg0" usage="optional"/>
>   </mapping>
>   <mapping name="testOneArgResponse" class="ws.TestOneArgResponse">
>     <namespace uri="http://ws/" default="elements"/>
>     <value name="return" field="_return" usage="optional"/>
>   </mapping>
>
>   

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