利用JaxWsDynamicClientFactory 调用webservice 报错解决

1.Spring启动跑错,不能存在多个实例cfx,经百度后发现为配置文件出错 改成

<jaxws:endpoint id="JK_webserviceLISImpl" implementor="com.ustcinfo.fccos.terminal.web.webservice.impl.JK_webserviceLISImpl" address="/JK_webService_LIS" />
	<jaxws:endpoint id="JK_webService_NGBOOSImpl" implementor="com.ustcinfo.fccos.terminal.web.webservice.impl.JK_webService_NGBOOSImpl" address="/JK_webService_NGBOOS" />
	

后成功启动服务成功

2.调用报错,本地利用JaxWsDynamicClientFactory 调用CFX服务报错 此时先确认maven引用,需添加这些引用

<!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-xjc -->
		<dependency>
		    <groupId>com.sun.xml.bind</groupId>
		    <artifactId>jaxb-xjc</artifactId>
		    <version>2.2.11</version>
		</dependency>
		<dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.2.11</version>
        </dependency>

        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-core</artifactId>
            <version>2.2.11</version>
        </dependency>

本地调用成功,部署到服务器发现报错

java.lang.IllegalStateException: Unable to create working directory /opt/fccos/tomcat-terminal-ws/temp/org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory@2cc821ef-1512537721871-src
	at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:345)
	at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:234)
	at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:227)
	at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:182)

查看代码发现本地生成动态客户端代码

try {
			client = dcf.createClient(WsAddress);

查看源码发现

 File src = new File(tmpdir, stem + "-src");
        if (!src.mkdir()) {
            throw new IllegalStateException("Unable to create working directory " + src.getPath());
        }
        try {
            Object writer = JAXBUtils.createFileCodeWriter(src);
            codeModel.build(writer);
        } catch (Exception e) {
            throw new IllegalStateException("Unable to write generated Java files for schemas: "
                                            + e.getMessage(), e);
        }
        File classes = new File(tmpdir, stem + "-classes");
        if (!classes.mkdir()) {
            throw new IllegalStateException("Unable to create working directory " + classes.getPath());
        }

自动创建文件,先推测为用户权限不够,发现linux上付文件夹权限为当前用户,经查看服务器上没有 /opt/fccos/tomcat-terminal-ws/temp/org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory@2cc821ef-1512537721871-src文件夹 查找原因,发现没有 /opt/fccos/tomcat-terminal-ws/temp/目录,尝试手动创建temp文件夹,尝试调用,成功,问题解决。大坑大坑

转载于:https://my.oschina.net/AHdaibo/blog/1585585

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值