1

サンプルの CXF Web サービス プログラムを作成し、Apache を使用してローカル マシンにデプロイしました。

これは私の WSDL URL です:

http://localhost:8080/SubstractWebService/SubWS?wsdl

そして、私はそれにアクセスすることができます。

しかし、クライアント プログラムを実行しようとすると、エラーが発生します -->


Exception in thread "main" javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
    at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:149)
    at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:97)
    at javax.xml.ws.Service.<init>(Unknown Source)
    at com.service.substract.subwsdlfile.SubWSDLFile_Service.<init>(SubWSDLFile_Service.java:43)
    at com.service.substract.subwsdlfile.SubWSDLFile_SubWSDLFileSOAP_Client.main(SubWSDLFile_SubWSDLFileSOAP_Client.java:53)
Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
    at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:94)
    at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:203)
    at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:147)
    ... 4 more
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: Problem parsing 'http://localhost:8080/SubstractWebService/SubWS?wsdl'.: java.io.FileNotFoundException: http://localhost:8080/SubstractWebService/SubWS?wsdl
    at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:244)
    at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:191)
    at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:92)
    ... 6 more
Caused by: java.io.FileNotFoundException: http://localhost:8080/SubstractWebService/SubWS?wsdl
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    ... 12 more

クライアントコード

package com.service.substract.subwsdlfile;

/**
 * Please modify this class to meet your needs
 * This class is not complete
 */

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlSeeAlso;

/**
 * This class was generated by Apache CXF 2.6.1
 * 2012-12-09T17:44:09.725+05:30
 * Generated source version: 2.6.1
 * 
 */
public final class SubWSDLFile_SubWSDLFileSOAP_Client {

    private static final QName SERVICE_NAME = new QName("http://substract.service.com/SubWSDLFile/", "SubWSDLFile");

    private SubWSDLFile_SubWSDLFileSOAP_Client() {
    }

    public static void main(String args[]) throws java.lang.Exception {
        URL wsdlURL = SubWSDLFile_Service.WSDL_LOCATION;
        if (args.length > 0 && args[0] != null && !"".equals(args[0])) { 
            File wsdlFile = new File(args[0]);
            try {
                if (wsdlFile.exists()) {
                    wsdlURL = wsdlFile.toURI().toURL();
                } else {
                    wsdlURL = new URL(args[0]);
                }
            } catch (MalformedURLException e) {
                e.printStackTrace();
            }
        }

        SubWSDLFile_Service ss = new SubWSDLFile_Service(wsdlURL, SERVICE_NAME);
        SubWSDLFile port = ss.getSubWSDLFileSOAP();  

        {
        System.out.println("Invoking substractOp...");
        com.service.substract.substractwsschema.SubsbtractRequest _substractOp_substractRequest = new com.service.substract.substractwsschema.SubsbtractRequest();
        _substractOp_substractRequest.setParam1(-735195532);
        _substractOp_substractRequest.setParam2(633197322);
        com.service.substract.substractwsschema.SubstractResponse _substractOp__return = port.substractOp(_substractOp_substractRequest);
        System.out.println("substractOp.result=" + _substractOp__return);


        }

        System.exit(0);
    }

}


package com.service.substract.subwsdlfile;

import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.Service;

/**
 * This class was generated by Apache CXF 2.6.1
 * 2012-12-09T17:44:09.805+05:30
 * Generated source version: 2.6.1
 * 
 */
@WebServiceClient(name = "SubWSDLFile", 
                  wsdlLocation = "http://localhost:8080/SubstractWebService?wsdl",
                  targetNamespace = "http://substract.service.com/SubWSDLFile/") 
public class SubWSDLFile_Service extends Service {

    public final static URL WSDL_LOCATION;

    public final static QName SERVICE = new QName("http://substract.service.com/SubWSDLFile/", "SubWSDLFile");
    public final static QName SubWSDLFileSOAP = new QName("http://substract.service.com/SubWSDLFile/", "SubWSDLFileSOAP");
    static {
        URL url = null;
        try {
           //url = new URL("http://localhost:8080/SubstractWebService?wsdl");
            url = new URL("http://localhost:8080/SubstractWebService");
        } catch (MalformedURLException e) {
            java.util.logging.Logger.getLogger(SubWSDLFile_Service.class.getName())
                .log(java.util.logging.Level.INFO, 
                     "Can not initialize the default wsdl from {0}", "http://localhost:8080/SubstractWebService?wsdl");
        }
        WSDL_LOCATION = url;
    }

    public SubWSDLFile_Service(URL wsdlLocation) {
        super(wsdlLocation, SERVICE);
    }

    public SubWSDLFile_Service(URL wsdlLocation, QName serviceName) {
        super(wsdlLocation, serviceName);
    }

    public SubWSDLFile_Service() {
        super(WSDL_LOCATION, SERVICE);
    }


    /**
     *
     * @return
     *     returns SubWSDLFile
     */
    @WebEndpoint(name = "SubWSDLFileSOAP")
    public SubWSDLFile getSubWSDLFileSOAP() {
        return super.getPort(SubWSDLFileSOAP, SubWSDLFile.class);
    }

    /**
     * 
     * @param features
     *     A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy.  Supported features not in the <code>features</code> parameter will have their default values.
     * @return
     *     returns SubWSDLFile
     */
    @WebEndpoint(name = "SubWSDLFileSOAP")
    public SubWSDLFile getSubWSDLFileSOAP(WebServiceFeature... features) {
        return super.getPort(SubWSDLFileSOAP, SubWSDLFile.class, features);
    }

}
4

0 に答える 0