bonjour a tous
dans le cadre d'un projet étudiant, je dois faire tourner un web service sur Jonas (4.8)
j'ai reussi a deployer l'exemple de jonas (la webapp wswarsample) et jaimerais mnt tester ce ws avec un client java standalone
j'ai lu le tuto de sun et celui d'ibm websphere et j'ai tenté le dynamic proxy
voici mon code
classe client
la SEI :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 import java.net.URL; import javax.xml.rpc.Service; import javax.xml.rpc.ServiceFactory; import javax.xml.namespace.QName; public class HelloClientDP { public static void main(String args[]) { try { // Create a service class with WSDL information. QName serviceName = new QName("http://ws.servlets.wssample.objectweb.org","JaxRpcEndpointInterfaceService"); URL wsdlLocation = new URL("http://localhost:9000/wswarsample/endpoints/jaxrpc?JWSDL"); ServiceFactory factory = ServiceFactory.newInstance(); Service service = factory.createService(wsdlLocation,serviceName); // Get an implementation for the SEI for the given port QName portName = new QName("http://ws.servlets.wssample.objectweb.org", "JaxRpcEndpoint1"); JaxRpcEndpointInterface quote = (JaxRpcEndpointInterface) service.getPort(portName,JaxRpcEndpointInterface.class); // Invoke the operation System.out.println(quote.sayHello("Buzz")); } catch (Throwable t) { t.printStackTrace(); } } }
et le wsdl
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 import java.rmi.Remote; import java.rmi.RemoteException; public interface JaxRpcEndpointInterface extends Remote { String sayHello(String name) throws RemoteException; int getCotes() throws RemoteException; }
apres compilation et execution :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69 <definitions name="" targetNamespace="http://ws.servlets.wssample.objectweb.org"> <message name="getCotesRequest"> </message> − <message name="sayHelloRequest"> <part name="in0" type="xsd:string"/> </message> − <message name="sayHelloResponse"> <part name="sayHelloReturn" type="xsd:string"/> </message> − <message name="getCotesResponse"> <part name="getCotesReturn" type="xsd:int"/> </message> − <portType name="JaxRpcEndpointInterface"> − <operation name="sayHello" parameterOrder="in0"> <input message="impl:sayHelloRequest" name="sayHelloRequest"/> <output message="impl:sayHelloResponse" name="sayHelloResponse"/> </operation> − <operation name="getCotes"> <input message="impl:getCotesRequest" name="getCotesRequest"/> <output message="impl:getCotesResponse" name="getCotesResponse"/> </operation> </portType> − <binding name="JaxRpcEndpointSoapBinding" type="impl:JaxRpcEndpointInterface"> <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> − <operation name="sayHello"> <wsdlsoap:operation soapAction="http://ws.servlets.wssample.objectweb.org/sayHello"/> − <input name="sayHelloRequest"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://ws.servlets.wssample.objectweb.org" use="encoded"/> </input> − <output name="sayHelloResponse"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://ws.servlets.wssample.objectweb.org" use="encoded"/> </output> </operation> − <operation name="getCotes"> <wsdlsoap:operation soapAction="http://ws.servlets.wssample.objectweb.org/getCotes"/> − <input name="getCotesRequest"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://ws.servlets.wssample.objectweb.org" use="encoded"/> </input> − <output name="getCotesResponse"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://ws.servlets.wssample.objectweb.org" use="encoded"/> </output> </operation> </binding> − <service name="JaxRpcEndpointInterfaceService"> − <port binding="impl:JaxRpcEndpointSoapBinding" name="JaxRpcEndpoint1"> <wsdlsoap:address location="http://localhost:9000/wswarsample/endpoints/jaxrpc"/> </port> − <port binding="impl:JaxRpcEndpointSoapBinding" name="EncryptedJaxRpcEndpoint"> <wsdlsoap:address location="http://localhost:9000/wswarsample/endpoints/encrypted"/> </port> </service> </definitions>
Axisfault
faultCode:{http://xml.apache.org/axis/}Server
faultSubcode:
faultString: Server Error
...
une idée
Partager