Ich versuch schon eine Ewigkeit eine ArrayList mit einem Webservice aufzurufen.
Mein Versuch:
Request:
[XML]
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://Webservice2/">
<soapenv:Header/>
<soapenv:Body>
<web:testArrayList/>
</soapenv:Body>
</soapenv:Envelope>
[/XML]
Response
[XML]
<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>
[/XML]
Nun habe ich folgende Zeile auskommentiert:
Als Response bekomme ich (fast das was ich will):
[XML]
<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>
[/XML]
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?
Mein Versuch:
Java:
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 double divideNumbers(int dividend, int divisor)
throws Exception {
if (divisor == 0) {
throw new Exception("Divisor cannot be zero!");
}
return (double)dividend/divisor;
}
@WebMethod
public ArrayList<Object> testArrayList() {
ArrayList<Object> results = new ArrayList<Object>();
int title = 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;
}
}
Request:
[XML]
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://Webservice2/">
<soapenv:Header/>
<soapenv:Body>
<web:testArrayList/>
</soapenv:Body>
</soapenv:Envelope>
[/XML]
Response
[XML]
<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>
[/XML]
Nun habe ich folgende Zeile auskommentiert:
Java:
@SOAPBinding(style=SOAPBinding.Style.RPC, use=SOAPBinding.Use.LITERAL)
Als Response bekomme ich (fast das was ich will):
[XML]
<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>
[/XML]
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?