I am not being able to access a WebService written in C #, from Java [closed]

0

I have a WebService written C # and I need to connect to it from Java to invoke methods.

Is it possible?

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);
    }
}

I'm trying this way but I'm having this error on the console:

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)
    
asked by anonymous 08.01.2016 / 19:06

1 answer

0

I recommend using JAX WS and CXF to make calls to the WebService in Java is much simpler.

Link example - Using Eclipse

Otherwise, if you are not using Eclipse IDE, you can run it by generating the stubs of the wsdl-based class and then run as it does in .NET.

Run this command at the prompt, where your consumer's source code is.

  

wsimport -keep -p com.acme.client link

Switch com.acme.client to your package.

In this case wsimport should generate some .java classes in place, according to the specification of your service, so you must have an ImplService.java file and you should instantiate this service and call your method, it can be seen an example www.thejavageek.com/2015/01/28/using-wsimport-command-generate-web-service-client.

I hope I have helped.

    
09.01.2016 / 05:03