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 Lukas Fischer / HTA <ia...@hta.fhz.ch> on 2006/04/06 10:56:54 UTC
simple webservice
Hello
I want to build a simple Webservice which returns a custom Object.
Object is very simple:
public class Luc {
public String name;
public String nachname;
public int alter;
public Luc(String name, String nachname, int alter) {
this.name = name;
this.nachname = nachname;
this.alter = alter;
}
}
services.xml is like (only relevant lines)
<operation name="getObject">
<messageReceiver
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
Public relevant line of Webservice is like:
public Luc getObject() throws Exception {
return new Luc("luc", "Fischer", 23);
}
WSDL: I can see that there is a namespace ns1:Luc. As a client I use C#
(VisualStudio). The client produces a class called Luc but of course
without any attributes, because they are not provided/specified in the wsdl!
How can I solve that? Do I need to write my own axis2-Receiver? Where is
the problem?
btw. The client works fine if the webservice just offers a simple
String, vgl. getVersion-sample! But with an object ...
<wsdl:definitions xmlns:ns1="http://org.apache.axis2/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://org.apache.axis2/" targetNamespace="http://org.apache.axis2/"><wsdl:types><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://org.apache.axis2/xsd" targetNamespace="http://org.apache.axis2/xsd" elementFormDefault="unqualified" attributeFormDefault="unqualified">
<xs:element type="ns1:Luc" name="Luc" />
<xs:complexType name="Luc">
<xs:sequence />
</xs:complexType>
<xs:element name="getObjectRequest">
<xs:complexType />
</xs:element>
<xs:element name="getObjectResponse">
<xs:complexType>
<xs:sequence>
<xs:element type="ns1:Luc" name="return" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getVersionRequest">
<xs:complexType />
</xs:element>
<xs:element name="getVersionResponse">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="return" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema></wsdl:types><wsdl:message name="getVersionResponseMessage"><wsdl:part name="part1" element="ns1:getVersionResponse" /></wsdl:message><wsdl:message name="getObjectResponseMessage"><wsdl:part name="part1" element="ns1:getObjectResponse" /></wsdl:message><wsdl:message name="getVersionRequestMessage"><wsdl:part name="part1" element="ns1:getVersionRequest" /></wsdl:message><wsdl:message name="getObjectRequestMessage"><wsdl:part name="part1" element="ns1:getObjectRequest" /></wsdl:message><wsdl:portType name="versionPort"><wsdl:operation name="getObject"><wsdl:input message="tns:getObjectRequestMessage" /><wsdl:output message="tns:getObjectResponseMessage" /></wsdl:operation><wsdl:operation name="getVersion"><wsdl:input message="tns:getVersionRequestMessage" /><wsdl:output message="tns:getVersionResponseMessage" /></wsdl:operation></wsdl:portType><wsdl:binding name="versionBinding" type="tns:versionPort"><soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /><wsdl:operation name="getObject"><soap:operation soapAction="getObject" style="document" /><wsdl:input><soap:body use="literal" namespace="http://www.org.apache.axis2" /></wsdl:input><wsdl:output><soap:body use="literal" namespace="http://www.org.apache.axis2" /></wsdl:output></wsdl:operation><wsdl:operation name="getVersion"><soap:operation soapAction="getVersion" style="document" /><wsdl:input><soap:body use="literal" namespace="http://www.org.apache.axis2" /></wsdl:input><wsdl:output><soap:body use="literal" namespace="http://www.org.apache.axis2" /></wsdl:output></wsdl:operation></wsdl:binding><wsdl:service name="version"><wsdl:port name="versionPortType0" binding="tns:versionBinding"><soap:address location="http://localhost:8080/axis2/services/version" /></wsdl:port></wsdl:service></wsdl:definitions>
Thank you in advance for any help.
Greets
luc
Re: simple webservice
Posted by Deepal Jayasinghe <de...@opensource.lk>.
hmmmm;
As I can see please make sure Luc to be a java bean , currently it is
not a bean;
it should as follwos then you wont have any problem.
public class Luc {
public String name;
public String nachname;
public int alter;
public Luc(String name, String nachname, int alter) {
this.name = name;
this.nachname = nachname;
this.alter = alter;
}
public void setName(String name){
this.name = name;
}
public String getName(){
return this.name;
}
public void setNachname(String nachname){
this.nachname= nachname;
}
public String getNachname(){
return this.nachname;
}
public void setAlter(int alter){
this.alter= alter;
}
public int getAlter(){
return this.alter;
}
}
Lukas Fischer / HTA wrote:
> Hello
>
> I want to build a simple Webservice which returns a custom Object.
>
> Object is very simple:
>
> public class Luc {
>
> public String name;
> public String nachname;
> public int alter;
> public Luc(String name, String nachname, int alter) {
> this.name = name;
> this.nachname = nachname;
> this.alter = alter;
> }
> }
>
>
> services.xml is like (only relevant lines)
> <operation name="getObject">
> <messageReceiver
> class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
> </operation>
>
> Public relevant line of Webservice is like:
> public Luc getObject() throws Exception {
> return new Luc("luc", "Fischer", 23);
> }
>
>
> WSDL: I can see that there is a namespace ns1:Luc. As a client I use
> C# (VisualStudio). The client produces a class called Luc but of
> course without any attributes, because they are not provided/specified
> in the wsdl!
> How can I solve that? Do I need to write my own axis2-Receiver? Where
> is the problem?
>
> btw. The client works fine if the webservice just offers a simple
> String, vgl. getVersion-sample! But with an object ...
>
> <wsdl:definitions xmlns:ns1="http://org.apache.axis2/xsd"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> xmlns:tns="http://org.apache.axis2/"
> targetNamespace="http://org.apache.axis2/"><wsdl:types><xs:schema
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:ns1="http://org.apache.axis2/xsd"
> targetNamespace="http://org.apache.axis2/xsd"
> elementFormDefault="unqualified" attributeFormDefault="unqualified">
> <xs:element type="ns1:Luc" name="Luc" />
> <xs:complexType name="Luc">
> <xs:sequence />
> </xs:complexType>
> <xs:element name="getObjectRequest">
> <xs:complexType />
> </xs:element>
> <xs:element name="getObjectResponse">
> <xs:complexType>
> <xs:sequence>
> <xs:element type="ns1:Luc" name="return" />
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> <xs:element name="getVersionRequest">
> <xs:complexType />
>
> </xs:element>
> <xs:element name="getVersionResponse">
> <xs:complexType>
> <xs:sequence>
> <xs:element type="xs:string" name="return" />
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:schema></wsdl:types><wsdl:message
> name="getVersionResponseMessage"><wsdl:part name="part1"
> element="ns1:getVersionResponse" /></wsdl:message><wsdl:message
> name="getObjectResponseMessage"><wsdl:part name="part1"
> element="ns1:getObjectResponse" /></wsdl:message><wsdl:message
> name="getVersionRequestMessage"><wsdl:part name="part1"
> element="ns1:getVersionRequest" /></wsdl:message><wsdl:message
> name="getObjectRequestMessage"><wsdl:part name="part1"
> element="ns1:getObjectRequest" /></wsdl:message><wsdl:portType
> name="versionPort"><wsdl:operation name="getObject"><wsdl:input
> message="tns:getObjectRequestMessage" /><wsdl:output
> message="tns:getObjectResponseMessage"
> /></wsdl:operation><wsdl:operation name="getVersion"><wsdl:input
> message="tns:getVersionRequestMessage" /><wsdl:output
> message="tns:getVersionResponseMessage"
> /></wsdl:operation></wsdl:portType><wsdl:binding name="versionBinding"
> type="tns:versionPort"><soap:binding
> transport="http://schemas.xmlsoap.org/soap/http" style="document"
> /><wsdl:operation name="getObject"><soap:operation
> soapAction="getObject" style="document" /><wsdl:input><soap:body
> use="literal" namespace="http://www.org.apache.axis2"
> /></wsdl:input><wsdl:output><soap:body use="literal"
> namespace="http://www.org.apache.axis2"
> /></wsdl:output></wsdl:operation><wsdl:operation
> name="getVersion"><soap:operation soapAction="getVersion"
> style="document" /><wsdl:input><soap:body use="literal"
> namespace="http://www.org.apache.axis2"
> /></wsdl:input><wsdl:output><soap:body use="literal"
> namespace="http://www.org.apache.axis2"
> /></wsdl:output></wsdl:operation></wsdl:binding><wsdl:service
> name="version"><wsdl:port name="versionPortType0"
> binding="tns:versionBinding"><soap:address
> location="http://localhost:8080/axis2/services/version"
> /></wsdl:port></wsdl:service></wsdl:definitions>
>
>
> Thank you in advance for any help.
>
> Greets
> luc
>
>
>
>
--
Thanks,
Deepal
................................................................
~Future is Open~