CXF客户端中Web服务的例外情况

时间:2014-01-08 10:53:55

标签: java web-services apache cxf

我为安全的网络服务(文件上传)生成了CXF客户端并尝试调用它。我在生成的文件夹中有以下文件

CarbonAppUploader(类) CarbonAppUploaderPortType(接口) UploadApp(类)。 ......... ..........

以下是我的客户

public class MyTest {
    public static void main(String[] args) throws IOException {
        JaxWsProxyFactoryBean clientFactory = new JaxWsProxyFactoryBean();
        clientFactory.setAddress( "https://localhost:8243/services/CarbonAppUploader.CarbonAppUploaderHttpsEndpoint/" );
        clientFactory.setServiceClass( CarbonAppUploader.class );
        clientFactory.setUsername("admin");
        clientFactory.setPassword("admin");
        UploadApp req = new UploadApp();

        FileInputStream fileInputStream;

        File file1 = new File("/home/malintha/support/....../AxisCApp-1.0.0.car");

        byte[] bFile = new byte[(int) file1.length()];


        //convert file into array of bytes
        fileInputStream = new FileInputStream(file1);
        fileInputStream.read(bFile);
        fileInputStream.close();

        //convert array of bytes into file
        FileOutputStream fileOuputStream =
                new FileOutputStream("/home/malintha/support/....../AxisCApp-1.0.0.car");
        fileOuputStream.write(bFile);
        fileOuputStream.close();
        org.wso2.carbon.application.upload.xsd.ObjectFactory of=new org.wso2.carbon.application.upload.xsd.ObjectFactory();
        UploadedFileItem file=new UploadedFileItem();
        file.setFileName(of.createUploadedFileItemFileName("AxisCApp-1.0.0.car"));
        file.setFileName(of.createUploadedFileItemFileType("CAR"));
        file.setDataHandler(of.createUploadedFileItemDataHandler(bFile));
        List<UploadedFileItem> flies=new ArrayList<UploadedFileItem>();
        flies.add(0,file);
        UploadApp myApp = new UploadApp();
        myApp.fileItems=flies;

        req.getFileItems().add( file );
        CarbonAppUploaderPortType uploadSvc = (CarbonAppUploaderPortType) clientFactory.create();
        uploadSvc.uploadApp( req );
    }
}

当我运行这个课程时,我得到了如下例外

信息:从类org.wso2.carbon.application.upload.C​​arbonAppUploader创建服务{{{​​3}}} CarbonAppUploaderService 线程“main”中的异常java.lang.IllegalArgumentException:org.wso2.carbon.application.upload.C​​arbonAppUploader不是接口     在java.lang.reflect.Proxy.getProxyClass0(Proxy.java:470)

clientFactory.create(); 方法调用会导致此异常。我该如何解决这个问题?

这是carbonAppUploader类

@WebServiceClient(name = "CarbonAppUploader", 
              wsdlLocation = "file:/home/malintha/software/axis2-bin/bin/src/org/CappUpload  /src/main/resources/myService.wsdl",
              targetNamespace = "http://upload.application.carbon.wso2.org") 
public class CarbonAppUploader extends Service {

public final static URL WSDL_LOCATION;

public final static QName SERVICE = new QName("http://upload.application.carbon.wso2.org", "CarbonAppUploader");
public final static QName CarbonAppUploaderHttpsSoap12Endpoint = new QName("http://upload.application.carbon.wso2.org", "CarbonAppUploaderHttpsSoap12Endpoint");
public final static QName CarbonAppUploaderHttpsSoap11Endpoint = new QName("http://upload.application.carbon.wso2.org", "CarbonAppUploaderHttpsSoap11Endpoint");
public final static QName CarbonAppUploaderHttpsEndpoint = new QName("http://upload.application.carbon.wso2.org", "CarbonAppUploaderHttpsEndpoint");
static {
    URL url = null;
    try {
        url = new URL("file:/home/malintha/software/axis2-bin/bin/src/org/CappUpload/src/main/resources/myService.wsdl");
    } catch (MalformedURLException e) {
        java.util.logging.Logger.getLogger(CarbonAppUploader.class.getName())
            .log(java.util.logging.Level.INFO, 
                 "Can not initialize the default wsdl from {0}", "file:/home/malintha/software/axis2-bin/bin/src/org/CappUpload/src/main/resources/myService.wsdl");
    }
    WSDL_LOCATION = url;
}

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

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

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


/**
 *
 * @return
 *     returns CarbonAppUploaderPortType
 */
@WebEndpoint(name = "CarbonAppUploaderHttpsSoap12Endpoint")
public CarbonAppUploaderPortType getCarbonAppUploaderHttpsSoap12Endpoint() {
    return super.getPort(CarbonAppUploaderHttpsSoap12Endpoint, CarbonAppUploaderPortType.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 CarbonAppUploaderPortType
 */
@WebEndpoint(name = "CarbonAppUploaderHttpsSoap12Endpoint")
public CarbonAppUploaderPortType getCarbonAppUploaderHttpsSoap12Endpoint(WebServiceFeature... features) {
    return super.getPort(CarbonAppUploaderHttpsSoap12Endpoint, CarbonAppUploaderPortType.class, features);
}
/**
 *
 * @return
 *     returns CarbonAppUploaderPortType
 */
@WebEndpoint(name = "CarbonAppUploaderHttpsSoap11Endpoint")
public CarbonAppUploaderPortType getCarbonAppUploaderHttpsSoap11Endpoint() {
    return super.getPort(CarbonAppUploaderHttpsSoap11Endpoint, CarbonAppUploaderPortType.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 CarbonAppUploaderPortType
 */
@WebEndpoint(name = "CarbonAppUploaderHttpsSoap11Endpoint")
public CarbonAppUploaderPortType getCarbonAppUploaderHttpsSoap11Endpoint(WebServiceFeature... features) {
    return super.getPort(CarbonAppUploaderHttpsSoap11Endpoint, CarbonAppUploaderPortType.class, features);
}
/**
 *
 * @return
 *     returns CarbonAppUploaderPortType
 */
@WebEndpoint(name = "CarbonAppUploaderHttpsEndpoint")
public CarbonAppUploaderPortType getCarbonAppUploaderHttpsEndpoint() {
    return super.getPort(CarbonAppUploaderHttpsEndpoint, CarbonAppUploaderPortType.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 CarbonAppUploaderPortType
 */
@WebEndpoint(name = "CarbonAppUploaderHttpsEndpoint")
public CarbonAppUploaderPortType getCarbonAppUploaderHttpsEndpoint(WebServiceFeature... features) {
    return super.getPort(CarbonAppUploaderHttpsEndpoint, CarbonAppUploaderPortType.class, features);
}

}

0 个答案:

没有答案