Tenho um WebService escrito C# e preciso de me conectar a ele a partir de Java para invocar uns métodos.
É possível?
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
public class SoapClient {
public static void main(String[] args) {
URL wsdlLocation = null;
try {
wsdlLocation = new URL("http://localhost:8000/eamsLink/RepositoryService/?wsdl");
} catch (MalformedURLException ex) {
Logger.getLogger(SoapClient.class.getName()).log(Level.SEVERE, null, ex);
}
QName qname = new QName("http://tempuri.org/", "RemoteSourceService");
Service service = Service.create(wsdlLocation, qname);
}
}
Estou a tentar desta maneira mas estou a ter este erro na consola:
Exception in thread "main" java.lang.NullPointerException
at com.sun.xml.internal.ws.model.wsdl.WSDLOperationImpl.freeze(Unknown Source)
at com.sun.xml.internal.ws.model.wsdl.WSDLPortTypeImpl.freeze(Unknown Source)
at com.sun.xml.internal.ws.model.wsdl.WSDLBoundPortTypeImpl.freeze(Unknown Source)
at com.sun.xml.internal.ws.model.wsdl.WSDLModelImpl.freeze(Unknown Source)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(Unknown Source)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(Unknown Source)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source)
at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(Unknown Source)
at javax.xml.ws.Service.<init>(Unknown Source)
at javax.xml.ws.Service.create(Unknown Source)
at SoapClient.main(SoapClient.java:22)
NullPointerException
e quais suas principais causas?