Complex parameters in axis2 web services
Hi everybody,
I'm developing a web service on which I need to use complex variables
as parameters, using Netbeans 6.7. For example I need to implement
these functions:
public ArrayList<String> get()
public String put(ArrayList<String> list)
I can build and deploy this WS without errors, but I was not able to
make a working client for consuming it. For developing the client I
used the Netbeans Web Service Client wizard... Here is the code:
- Web Service
public ArrayList<String> get()
{
ArrayList<String> list = new ArrayList<String>();
list.add("a1");
list.add("a2");
return list;
}
public String put(ArrayList<String> list)
{
String r = null;
for(int i=0; i<list.size(); i++)
r = r +","+ list.get(i);
return r;
}
- Client
//Put
try {
wslist.Wslist service = new wslist.Wslist();
wslist.WslistPortType port = service.getWslistHttpSoap12Endpoint();
ArrayList<String> list = new ArrayList();
list.add("a1");
list.add("a2");
java.lang.String result = port.put(list);
System.out.println("Result = "+result);
} catch (Exception ex) {
System.err.println(ex);
}
- When the client runs, I get this exception for port.put(list):
javax.xml.ws.WebServiceException: javax.xml.bind.MarshalException
- with linked exception:
[javax.xml.bind.JAXBException: class java.util.ArrayList nor any of
its super class is known to this context.]
- This is the generated WSDL file part relative to the put()
function:
<xs:element name="put">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="list" nillable="true"
type="xs:anyType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
How can I do? I hope you can help me
Thank you very much in advance for your help!