Hallo,
ich versuche, einen Client zu programmieren, der auf einen WebService zugreift.
Habe vom Entwickler des WebServices die entsprechende wsdl-Datei bekommen und versuche jetzt, Abfragen zu senden und auch Antworten zu bekommen.
Bis jetzt habe ich folgendes gemacht:
- aus der wsdl-Datei mit WSDL2Java die entsprechenden Java-Files erzeugt
- ein einfaches Client-Programm geschrieben, das erstmal nur auf eine der Methoden des Service zugreifen soll und das Ergebnis als String ausgibt
- das Programm kompiliert und gestartet
>>>>>Leider kriege ich immer nur UnknownHostExceptions
Ein Ausschnitt aus meinem Client-Programm:
Kann mir irgendjemand sagen, was ich falsch mache? Sitz jetzt schon über ne Woche daran und bin am verzweifeln. Kann doch nich so schwer sein, auf einen WebService zuzugreifen.
Alle Beispiele (aus Tutorials...), die ich ausprobiert habe, funktionieren. Da wird allerdings auch immer auf localhost zugegriffen.
ich versuche, einen Client zu programmieren, der auf einen WebService zugreift.
Habe vom Entwickler des WebServices die entsprechende wsdl-Datei bekommen und versuche jetzt, Abfragen zu senden und auch Antworten zu bekommen.
Bis jetzt habe ich folgendes gemacht:
- aus der wsdl-Datei mit WSDL2Java die entsprechenden Java-Files erzeugt
- ein einfaches Client-Programm geschrieben, das erstmal nur auf eine der Methoden des Service zugreifen soll und das Ergebnis als String ausgibt
- das Programm kompiliert und gestartet
>>>>>Leider kriege ich immer nur UnknownHostExceptions
- AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.net.UnknownHostException: ollilap
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:java.net.UnknownHostException: ollilap
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSocketFactory.java:153)
at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSocketFactory.java:120)
at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:181)
at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:397)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:135)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2754)
at org.apache.axis.client.Call.invoke(Call.java:2737)
at org.apache.axis.client.Call.invoke(Call.java:2413)
at org.apache.axis.client.Call.invoke(Call.java:2336)
at org.apache.axis.client.Call.invoke(Call.java:1793)
at ollilap.axis.services.XXXWebService.XXXWebServiceSoapBindingStub.operation1 XXXWebServiceSoapBindingStub.java:547)
at XXXWebTest.runIt(XXXWebTest.java:38
at XXXWebTest.main(XXXWebTest.java:26)
{http://xml.apache.org/axis/}hostnameell1
java.net.UnknownHostException: ollilap
at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrateg
y.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2754)
at org.apache.axis.client.Call.invoke(Call.java:2737)
at org.apache.axis.client.Call.invoke(Call.java:2413)
at org.apache.axis.client.Call.invoke(Call.java:2336)
at org.apache.axis.client.Call.invoke(Call.java:1793)
at ollilap.axis.services.XXXWebService.XXXWebServiceSoapBindingStub.operation1(XXXWebServiceSoapBindingStub.java:547)
at XXXWebTest.runIt(XXXWebTest.java:38
at XXXWebTest.main(XXXWebTest.java:26)
Caused by: java.net.UnknownHostException: ollilap
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSoc
ketFactory.java:153)
at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSoc
ketFactory.java:120)
at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:1
81)
at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.ja
va:397)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:135)
... 12 more
Ein Ausschnitt aus meinem Client-Programm:
Code:
public class XXXWebTest
{
public static void main(String [] args) throws Exception {
try {
runIt();
} catch(Exception e) {
e.printStackTrace();
}
}
private static void runIt() throws Exception {
String ret = "";
XXXWebServiceService service = new XXXWebServiceServiceLocator();
XXXWebService port = service.getXXXWebService();
ret = (String) port.operation1(null,null,"String1","String2",null,null,null,true,new int[] {0});
System.out.println(ret);
}
}
Alle Beispiele (aus Tutorials...), die ich ausprobiert habe, funktionieren. Da wird allerdings auch immer auf localhost zugegriffen.