Ich versuche eine ArrayList mit einem Webservice aufzurufen.
Mein Versuch:
Request (über SoapUI):
Response (über SoapUI):
Mein Versuch das ganze als Object[] zurückzugeben:
Als Response bekomme ich (leider kein AnyType):
und:
und einen Validerungsfehler:
Invalid xsi:type qname: 'xs:int'
Invalid xsi:type qname: 'xs:string'
Invalid xsi:type qname: 'xs:double'
Invalid xsi:type qname: 'xs:long'
Invalid xsi:type qname: 'xs:string'
Was mache ich falsch und wie kann ich das Problem?
Info: Wenn ich den Code mit Axis2 laufen lasse kommt es zu keinem Validierungsfehler.
Mein Versuch:
Code:
import java.util.ArrayList;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
/**
* Web Service End-point implementation class
*/
@WebService(name = "TEST_name", serviceName = "TEST_serviceName")
@SOAPBinding(style=SOAPBinding.Style.RPC, use=SOAPBinding.Use.LITERAL)
public class Hello {
// Constructor
public void Hello() {}
@WebMethod
public String sayHello(String name) {
return "Hello, " + name + ".";
}
@WebMethod
public int addNumbers(int number1, int number2) {
return number1 + number2;
}
@WebMethod
public ArrayList<Object> testArrayList() {
ArrayList<Object> results = new ArrayList<Object>();
int nr = 1;
String description = "Description";
double d = 44.66;
long l = 66;
String st = "Stringtest";
results.add(title);
results.add(description);
results.add(d);
results.add(l);
results.add(st);
return results;
}
}
Code:
import javax.xml.ws.Endpoint;
public class Server {
public static void main (String args[]) {
Hello server = new Hello();
Endpoint.publish("http://localhost:8080/Server", server);
}
}
Request (über SoapUI):
Code:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://Webservice2/">
<soapenv:Header/>
<soapenv:Body>
<web:testArrayList/>
</soapenv:Body>
</soapenv:Envelope>
Response (über SoapUI):
Code:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:testArrayListResponse xmlns:ns2="http://Webservice2/">
<return/>
</ns2:testArrayListResponse>
</S:Body>
</S:Envelope>
Mein Versuch das ganze als Object[] zurückzugeben:
Code:
public Object[] testArrayList2(){
ArrayList<Object> results = new ArrayList<Object>();
int title = 1;
String description = "Description";
double url = 44.66;
long displayUrl = 66;
String dateTime = "DateTime";
results.add(title);
results.add(description);
results.add(url);
results.add(displayUrl);
results.add(dateTime);
Object[] test = results.toArray();
return test;
}
Als Response bekomme ich (leider kein AnyType):
Code:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:testArrayListResponse xmlns:ns2="http://Webservice2/">
<return xsi:type="xs:int" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">1</return>
<return xsi:type="xs:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">Description</return>
<return xsi:type="xs:double" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">44.66</return>
<return xsi:type="xs:long" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">66</return>
<return xsi:type="xs:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">Stringtest</return>
</ns2:testArrayListResponse>
</S:Body>
</S:Envelope>
und:
und einen Validerungsfehler:
Invalid xsi:type qname: 'xs:int'
Invalid xsi:type qname: 'xs:string'
Invalid xsi:type qname: 'xs:double'
Invalid xsi:type qname: 'xs:long'
Invalid xsi:type qname: 'xs:string'
Was mache ich falsch und wie kann ich das Problem?
Info: Wenn ich den Code mit Axis2 laufen lasse kommt es zu keinem Validierungsfehler.