I am trying to create a client for my WSDL service. When I try and consume/use the service I get this error:
Exception in thread "main" javax.xml.ws.WebServiceException: Undefined port type:
I am generating my WSDL binding via JAXWS. The only port type which may be undefined is the String[][]
input for the register function (originally I used ArrayLists however, they can't be parsed correctly by the JAXWS so I changed them to arrays).
<message name="register">
<part xmlns:ns1="http://jaxb.dev.java.net/array" name="endUserDetailsInput" type="ns1:stringArrayArray"/>
</message>
So when I try and use the register method in the CLI:
Controller controller = new Controller();
//Hardcoded Student/AcademicStaff here.
String[] rec1 = {"0","Student"};
String[] rec2 = {"1","Student"};
String[] rec3 = {"2","Student"};
String[] rec4 = {"3","Student"};
String[] rec5 = {"4","Student"};
String[] rec6 = {"5","AcademicStaff"};
String[] rec7 = {"6","AcademicStaff"};
String[][] endUserList = {rec1,rec2,rec3,rec4,rec5,rec6,rec7};
controller.batchReg(endUserList);
and in the controller:
public class Controller {
public void batchReg(String[][] records){
URL url = null;
try {
url = new URL("http://localhost:8080/EndUserService/?wsdl");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (url == null) {
System.out.println("Failed");
}
QName qname = new QName("http://EndUserService/","EndUserServiceImplService");
Service service = Service.create(url,qname);
EndUserService obj = service.getPort(EndUserService.class);
obj.register(records);
System.out.println("Complete!");
}
}
I get the error. If required I can provide the full WSDL file and other files but I think it must be that part because the other inputs and outputs in the system are all primitive types.
If I can't use ArrayLists or Arrays of Arrays, could you suggest an alternative data type that would work, or a work around? I could manually register each end user but that would be a task onto itself, and I wanted to avoid it if possible.
Any help appreciated.
Full Error Print out
Exception in thread "main" javax.xml.ws.WebServiceException: Undefined port type: {http://controller/}EndUserService
at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:406)
at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:412)
at javax.xml.ws.Service.getPort(Service.java:188)
at controller.Controller.batchReg(Controller.java:28)
at view.CLI.main(CLI.java:21)
Seems to be your webservice anotation doesn't has an endpointInterface.
You need to provide the port name
EndUserService obj = service.getPort(qname,EndUserService.class);
Or include an endpointInterface in you @WebService annotation
@WebService(endpointInterface="com.something"...)