如何使用WSDL连接到远程Web服务

时间:2020-03-23 06:53:23

标签: java soap wsdl soap-client

任务是连接到远程Web服务。它的描述采用WSDL的形式。 我创建一个服务描述:

"C:\Program Files (x86)\Java\jdk1.8.0_171\bin\wsimport.exe" -keep http://b2b.soglasie.ru:81/scoring/scoring?wsdl

然后我创建接收到的服务:

 ScoringService s = new ScoringService();

初始化服务时发生错误:

java.lang.NullPointerException
0 = {StackTraceElement@3701} "javax.xml.ws.Service.<init>(Service.java:112)"
1 = {StackTraceElement@3702} "ru.soglasie.b2b.scoring.ScoringService.<init>(ScoringService.java:38)"

ScoringService

@WebServiceClient(name = "ScoringService", targetNamespace = "http://scoring.b2b.soglasie.ru/", wsdlLocation = "http://b2b.soglasie.ru:81/scoring/scoring?wsdl")
public class ScoringService
    extends Service
{

    private final static URL SCORINGSERVICE_WSDL_LOCATION;
    private final static WebServiceException SCORINGSERVICE_EXCEPTION;
    private final static QName SCORINGSERVICE_QNAME = new QName("http://scoring.b2b.soglasie.ru/", "ScoringService");

    static {
        URL url = null;
        WebServiceException e = null;
        try {
            url = new URL("http://b2b.soglasie.ru:81/scoring/scoring?wsdl");
        } catch (MalformedURLException ex) {
            e = new WebServiceException(ex);
        }
        SCORINGSERVICE_WSDL_LOCATION = url;
        SCORINGSERVICE_EXCEPTION = e;
    }

    public ScoringService() {
        super(__getWsdlLocation(), SCORINGSERVICE_QNAME);
    }

javax.mxl.ws.Service

package javax.xml.ws;

import java.net.URL;
import java.util.Iterator;
import java.util.concurrent.Executor;
import javax.xml.bind.JAXBContext;
import javax.xml.namespace.QName;
import javax.xml.ws.handler.HandlerResolver;
import javax.xml.ws.spi.Provider;
import javax.xml.ws.spi.ServiceDelegate;

public class Service {
    private ServiceDelegate delegate;

    protected Service(URL wsdlDocumentLocation, QName serviceName) {
        this.delegate = Provider.provider().createServiceDelegate(wsdlDocumentLocation, serviceName, this.getClass());
    }

如何解决此错误?

0 个答案:

没有答案
相关问题