HI,
I decided to write WS client to test my web service. I looked the hello example in jboss documentation in chapter 12. Here my code:
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.Call;
import javax.xml.rpc.Service;
import java.net.URL;
public class TestWSClient {
public static void main(String[] args) {
String nmsp = "http://test.webservice.oceaninfo.ru";
String qnameService = "TestWSService";
String qnamePort = "TestWSInterfacePort";
String urlstr = "http://debug/testws/Test?wsdl";
try {
URL url = new URL(urlstr);
ServiceFactory factory = ServiceFactory.newInstance();
javax.xml.rpc.Service serv = factory.createService(url, new QName(nmsp, qnameService));
Call call = serv.createCall(new QName(nmsp,qnamePort),new QName(nmsp,"getId"));
System.out.println("output:" + call.invoke(new Object[] {"argument"}));
} catch (Exception e) {
e.printStackTrace();
}
}
}
But I have the error:
javax.xml.rpc.ServiceException: Error processing WSDL document:
javax.xml.rpc.ServiceException: Error processing WSDL document:
javax.xml.rpc.ServiceException: Cannot find service: {http://test.webservice.oceaninfo.ru}TestWSService
at org.jboss.axis.client.Service.initService(Service.java:289)
at org.jboss.axis.client.Service.(Service.java:191)
at org.jboss.webservice.client.ServiceImpl.(ServiceImpl.java:110)
at org.jboss.webservice.client.ServiceFactoryImpl.createService(ServiceFactoryImpl.java:111)
at TestWSClient.main(TestWSClient.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
I used wscompile to generate WSDL.
It's strange, because I think I used right url. What is wrong?
Thank you.