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 Guoping Zhang <zh...@gmail.com> on 2007/09/17 10:47:17 UTC

[axis2] Is there any example of building webservice from Java class?

for example:

class HelloWorld
{
    public String sayHello(String s)
    {
        return s;
    }
}

Instead of using OMElement as argument

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


Re: [axis2] Is there any example of building webservice from Java class?

Posted by Anne Thomas Manes <at...@gmail.com>.
I noticed that the WSDL's schema says:

         elementFormDefault="unqualified"

I thought that java2wsdl generates a schema with

         elementFormDefault="qualified"

by default.

The request message qualifies the child element "ns1:name" (which is
invalid according to the schema). The response message does not
qualify the child element "return" (which is valid according to the
schema). Interesting that the client generates an invalid message and
faults on a valid message.

Anne

On 9/18/07, Deepal jayasinghe <de...@gmail.com> wrote:
> Hmm ,create a JIRA and attach your java class.
> > Hi Deepal,
> >
> > I started by creating a java class A.java and use java2wsdl to create
> > a wsdl and wsdl2java to create Stubs.
> try to deploy the service and then do the ?wsdl on it and generate the
> code using that.
> > Client still get the exception:
> > Caused by: org.apache.axis2.databinding.ADBException: Unexpected
> > subelement return
> >       at org.apache.ws.axis2.AStub$SayHelloResponse$Factory.parse(AStub.java:1164)
> >       ... 3 more
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

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


Re: [axis2] Is there any example of building webservice from Java class?

Posted by Deepal jayasinghe <de...@gmail.com>.
Hmm ,create a JIRA and attach your java class.
> Hi Deepal,
>
> I started by creating a java class A.java and use java2wsdl to create
> a wsdl and wsdl2java to create Stubs. 
try to deploy the service and then do the ?wsdl on it and generate the
code using that.
> Client still get the exception:
> Caused by: org.apache.axis2.databinding.ADBException: Unexpected
> subelement return
> 	at org.apache.ws.axis2.AStub$SayHelloResponse$Factory.parse(AStub.java:1164)
> 	... 3 more
>   


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


Re: [axis2] Is there any example of building webservice from Java class?

Posted by Guoping Zhang <zh...@gmail.com>.
Hi Deepal,

I started by creating a java class A.java and use java2wsdl to create
a wsdl and wsdl2java to create Stubs. Client still get the exception:
Caused by: org.apache.axis2.databinding.ADBException: Unexpected
subelement return
	at org.apache.ws.axis2.AStub$SayHelloResponse$Factory.parse(AStub.java:1164)
	... 3 more
"return" element's namespaceUri is "".

Following is request and response and wsdl. Can you give some
suggestions about this?

<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope
xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><ns1:sayHello
xmlns:ns1="http://ws.apache.org/axis2"><ns1:name>aaaaaaaaaaa</ns1:name></ns1:sayHello></soapenv:Body></soapenv:Envelope>

<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope
xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body>
<ns:sayHelloResponse
xmlns:ns="http://ws.apache.org/axis2"><return>Hello
aaaaaaaaaaa</return></ns:sayHelloResponse></soapenv:Body></soapenv:Envelope>




<wsdl:definitions targetNamespace="http://ws.apache.org/axis2">
−
	<wsdl:types>
−
	<xs:schema attributeFormDefault="qualified"
elementFormDefault="unqualified"
targetNamespace="http://ws.apache.org/axis2">
−
	<xs:element name="add">
−
	<xs:complexType>
−
	<xs:sequence>
<xs:element minOccurs="0" name="a" type="xs:int"/>
<xs:element minOccurs="0" name="b" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
−
	<xs:element name="addResponse">
−
	<xs:complexType>
−
	<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
−
	<xs:element name="sayHello">
−
	<xs:complexType>
−
	<xs:sequence>
<xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
−
	<xs:element name="sayHelloResponse">
−
	<xs:complexType>
−
	<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
−
	<wsdl:message name="addRequest">
<wsdl:part name="parameters" element="ns0:add"/>
</wsdl:message>
−
	<wsdl:message name="addResponse">
<wsdl:part name="parameters" element="ns0:addResponse"/>
</wsdl:message>
−
	<wsdl:message name="sayHelloRequest">
<wsdl:part name="parameters" element="ns0:sayHello"/>
</wsdl:message>
−
	<wsdl:message name="sayHelloResponse">
<wsdl:part name="parameters" element="ns0:sayHelloResponse"/>
</wsdl:message>
−
	<wsdl:portType name="APortType">
−
	<wsdl:operation name="add">
<wsdl:input message="ns0:addRequest" wsaw:Action="urn:add"/>
<wsdl:output message="ns0:addResponse" wsaw:Action="urn:addResponse"/>
</wsdl:operation>
−
	<wsdl:operation name="sayHello">
<wsdl:input message="ns0:sayHelloRequest" wsaw:Action="urn:sayHello"/>
<wsdl:output message="ns0:sayHelloResponse" wsaw:Action="urn:sayHelloResponse"/>
</wsdl:operation>
</wsdl:portType>
−
	<wsdl:binding name="ASOAP11Binding" type="ns0:APortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document"/>
−
	<wsdl:operation name="add">
<soap:operation soapAction="urn:add" style="document"/>
−
	<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
−
	<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
−
	<wsdl:operation name="sayHello">
<soap:operation soapAction="urn:sayHello" style="document"/>
−
	<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
−
	<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
−
	<wsdl:binding name="ASOAP12Binding" type="ns0:APortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document"/>
−
	<wsdl:operation name="add">
<soap12:operation soapAction="urn:add" style="document"/>
−
	<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
−
	<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
−
	<wsdl:operation name="sayHello">
<soap12:operation soapAction="urn:sayHello" style="document"/>
−
	<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
−
	<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
−
	<wsdl:binding name="AHttpBinding" type="ns0:APortType">
<http:binding verb="POST"/>
−
	<wsdl:operation name="add">
<http:operation location="A/add"/>
−
	<wsdl:input>
<mime:content type="text/xml" part="add"/>
</wsdl:input>
−
	<wsdl:output>
<mime:content type="text/xml" part="add"/>
</wsdl:output>
</wsdl:operation>
−
	<wsdl:operation name="sayHello">
<http:operation location="A/sayHello"/>
−
	<wsdl:input>
<mime:content type="text/xml" part="sayHello"/>
</wsdl:input>
−
	<wsdl:output>
<mime:content type="text/xml" part="sayHello"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
−
	<wsdl:service name="A">
−
	<wsdl:port name="ASOAP11port_http" binding="ns0:ASOAP11Binding">
<soap:address location="http://gpzhang-desktop:8080/axis2/services/A"/>
</wsdl:port>
−
	<wsdl:port name="ASOAP12port_http" binding="ns0:ASOAP12Binding">
<soap12:address location="http://gpzhang-desktop:8080/axis2/services/A"/>
</wsdl:port>
−
	<wsdl:port name="AHttpport" binding="ns0:AHttpBinding">
<http:address location="http://gpzhang-desktop:8080/axis2/services/A"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>


2007/9/17, Deepal jayasinghe <de...@gmail.com>:
> Please try to generate code again and see.
>
> Thanks
> Deepal
> > Hi Deepal,
> >
> > Thanks for your reply.I follow the steps of creating pojo services but
> > i got following exception when i was invoking services throug
> > wsdl2java generated stub.
> > The client is asking for "return" element which has
> > nameURI=http://ws.apache.org/axis2,
> > but server sends out its nameUr""
> >
> > org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException:
> > Unexpected subelement return
> >       at org.apache.axis2.AxisFault.makeFault(AxisFault.java:417)
> >       at org.apache.ws.axis2.AStub.fromOM(AStub.java:719)
> >       at org.apache.ws.axis2.AStub.sayHello(AStub.java:391)
> >       at test.Client.main(Client.java:22)
> > Caused by: java.lang.Exception:
> > org.apache.axis2.databinding.ADBException: Unexpected subelement
> > return
> >       at org.apache.ws.axis2.AStub$SayHelloResponse$Factory.parse(AStub.java:1168)
> >       at org.apache.ws.axis2.AStub.fromOM(AStub.java:716)
> >       ... 2 more
> > Caused by: org.apache.axis2.databinding.ADBException: Unexpected
> > subelement return
> >       at org.apache.ws.axis2.AStub$SayHelloResponse$Factory.parse(AStub.java:1164)
> >       ... 3 more
> >
> > Thanks,
> > Guo-ping Zhang
> >
> > 2007/9/17, Deepal jayasinghe <de...@gmail.com>:
> >
> >> I think following article will help you.
> >>
> >> http://wso2.org/library/2546
> >>
> >> Thanks
> >> Deepal
> >>
> >>> for example:
> >>>
> >>> class HelloWorld
> >>> {
> >>>     public String sayHello(String s)
> >>>     {
> >>>         return s;
> >>>     }
> >>> }
> >>>
> >>> Instead of using OMElement as argument
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> >>> For additional commands, e-mail: axis-user-help@ws.apache.org
> >>>
> >>>
> >>>
> >>>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> >> For additional commands, e-mail: axis-user-help@ws.apache.org
> >>
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

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


Re: [axis2] Is there any example of building webservice from Java class?

Posted by Deepal jayasinghe <de...@gmail.com>.
Please try to generate code again and see.

Thanks
Deepal
> Hi Deepal,
>
> Thanks for your reply.I follow the steps of creating pojo services but
> i got following exception when i was invoking services throug
> wsdl2java generated stub.
> The client is asking for "return" element which has
> nameURI=http://ws.apache.org/axis2,
> but server sends out its nameUr""
>
> org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException:
> Unexpected subelement return
> 	at org.apache.axis2.AxisFault.makeFault(AxisFault.java:417)
> 	at org.apache.ws.axis2.AStub.fromOM(AStub.java:719)
> 	at org.apache.ws.axis2.AStub.sayHello(AStub.java:391)
> 	at test.Client.main(Client.java:22)
> Caused by: java.lang.Exception:
> org.apache.axis2.databinding.ADBException: Unexpected subelement
> return
> 	at org.apache.ws.axis2.AStub$SayHelloResponse$Factory.parse(AStub.java:1168)
> 	at org.apache.ws.axis2.AStub.fromOM(AStub.java:716)
> 	... 2 more
> Caused by: org.apache.axis2.databinding.ADBException: Unexpected
> subelement return
> 	at org.apache.ws.axis2.AStub$SayHelloResponse$Factory.parse(AStub.java:1164)
> 	... 3 more
>
> Thanks,
> Guo-ping Zhang
>
> 2007/9/17, Deepal jayasinghe <de...@gmail.com>:
>   
>> I think following article will help you.
>>
>> http://wso2.org/library/2546
>>
>> Thanks
>> Deepal
>>     
>>> for example:
>>>
>>> class HelloWorld
>>> {
>>>     public String sayHello(String s)
>>>     {
>>>         return s;
>>>     }
>>> }
>>>
>>> Instead of using OMElement as argument
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>>
>>>
>>>
>>>       
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
>   


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


Re: [axis2] Is there any example of building webservice from Java class?

Posted by Guoping Zhang <zh...@gmail.com>.
Hi Deepal,

Thanks for your reply.I follow the steps of creating pojo services but
i got following exception when i was invoking services throug
wsdl2java generated stub.
The client is asking for "return" element which has
nameURI=http://ws.apache.org/axis2,
but server sends out its nameUr""

org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException:
Unexpected subelement return
	at org.apache.axis2.AxisFault.makeFault(AxisFault.java:417)
	at org.apache.ws.axis2.AStub.fromOM(AStub.java:719)
	at org.apache.ws.axis2.AStub.sayHello(AStub.java:391)
	at test.Client.main(Client.java:22)
Caused by: java.lang.Exception:
org.apache.axis2.databinding.ADBException: Unexpected subelement
return
	at org.apache.ws.axis2.AStub$SayHelloResponse$Factory.parse(AStub.java:1168)
	at org.apache.ws.axis2.AStub.fromOM(AStub.java:716)
	... 2 more
Caused by: org.apache.axis2.databinding.ADBException: Unexpected
subelement return
	at org.apache.ws.axis2.AStub$SayHelloResponse$Factory.parse(AStub.java:1164)
	... 3 more

Thanks,
Guo-ping Zhang

2007/9/17, Deepal jayasinghe <de...@gmail.com>:
> I think following article will help you.
>
> http://wso2.org/library/2546
>
> Thanks
> Deepal
> > for example:
> >
> > class HelloWorld
> > {
> >     public String sayHello(String s)
> >     {
> >         return s;
> >     }
> > }
> >
> > Instead of using OMElement as argument
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

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


Re: [axis2] Is there any example of building webservice from Java class?

Posted by Deepal jayasinghe <de...@gmail.com>.
I think following article will help you.

http://wso2.org/library/2546

Thanks
Deepal
> for example:
>
> class HelloWorld
> {
>     public String sayHello(String s)
>     {
>         return s;
>     }
> }
>
> Instead of using OMElement as argument
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
>   


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