I am trying to use my WSDL SOAP Service:
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(qname,EndUserService.class);
obj.register(records);
System.out.println("Complete!");
}
Yet when I run this, I receive this error:
Exception in thread "main" javax.xml.ws.WebServiceException: {http://EndUserService/}EndUserServiceImplService is not a valid port. Valid ports are: {http://EndUserService/}EndUserServiceImplPort
So then I changed the QName declaration to:
QName qname = new QName("http://EndUserService/","EndUserServiceImplPort");
But then I get this error:
Exception in thread "main" javax.xml.ws.WebServiceException: {http://EndUserService/}EndUserServiceImplPort is not a valid service. Valid services are: {http://EndUserService/}EndUserServiceImplService
Which is what I had previously.
WSDL Exerpt
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://EndUserService/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://EndUserService/" name="EndUserServiceImplService">
<types>
<xsd:schema>
<xsd:import namespace="http://jaxb.dev.java.net/array" schemaLocation="http://localhost:8080/EndUserService/?xsd=1"/>
</xsd:schema>
<xsd:schema>
<xsd:import namespace="http://EndUserService/" schemaLocation="http://localhost:8080/EndUserService/?xsd=2"/>
</xsd:schema>
</types>
Had to add a specific port QName
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");
System.out.println(url);
Service service = Service.create(url,qname);
QName qport = new QName("http://EndUserService/","EndUserServiceImplPort");
EndUserService obj = service.getPort( qport,EndUserService.class );
obj.register(records);
System.out.println("Complete!");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.