上一篇我用acgei绑定的方式创建了一个Web Service。后面做一个Client进行调用验证一下。
java客户端
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.mms.webservice.client;
import java.util.List;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.mms.webservice.VendorMaintenance;
import com.mrm.model.other.Vendor;
public final class ClientVendor {
private ClientVendor() {
}
public static void main(String args[]) throws Exception {
// START SNIPPET: client
ClassPathXmlApplicationContext context
= new ClassPathXmlApplicationContext(new String[] {"com/tnt/mms/webservice/client/client-vendor-beans.xml"});
VendorMaintenance client = (VendorMaintenance)context.getBean("client");
Vendor ls =client.get("10116");
System.out.println("Response: " + ls.getEngName());
List<Vendor> rs=client.getList();
System.out.println("Response: " + rs.size());
System.out.println("Response: " + rs.get(0).getEngName());
System.exit(0);
// END SNIPPET: client
}
}
xml配置
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!-- START SNIPPET: beans -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schema/jaxws.xsd">
<!-- Configure CXF to use Aegis data binding instead of JAXB -->
<bean id="aegisBean" class="org.apache.cxf.aegis.databinding.AegisDatabinding" scope="prototype"/>
<bean id="jaxwsAndAegisServiceFactory"
class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean"
scope="prototype">
<property name="dataBinding" ref="aegisBean"/>
<property name="serviceConfigurations">
<list>
<bean class="org.apache.cxf.jaxws.support.JaxWsServiceConfiguration"/>
<bean class="org.apache.cxf.aegis.databinding.AegisServiceConfiguration"/>
<bean class="org.apache.cxf.service.factory.DefaultServiceConfiguration"/>
</list>
</property>
</bean>
<bean id="client" class="com.tnt.mms.webservice.VendorMaintenance"
factory-bean="clientFactory" factory-method="create"/>
<bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass" value="com.tnt.mms.webservice.VendorMaintenance"/>
<property name="address" value="http://localhost:8080/extjsmms/VendorMaintenance"/>
<property name="serviceFactory" ref="jaxwsAndAegisServiceFactory"/>
</bean>
</beans>
<!-- END SNIPPET: beans -->
运行client就可以调试结果。
总结
使用Acegi进行数据绑定后,在调用的时候一样要进行对应的acegi绑定。否则数据出不来。但不知道异构系统相互调用时如何进行。以后再研究了
分享到:
相关推荐
cxf客户端调用axis服务端流程
CXF客户端调用例子,本例子开发语言为JAVA,包内包含服务端跟客户端
cxf客户端调用axis服务端流程.docxcxf客户端调用axis服务端流程.docx
Java 调用webservice cxf客户端调用demo和服务端,包含jar包,服务端发布后直接用客户端调用
CXF 开发手册, 包括下载,配置,客户端调用远程服务以及发布自己的接口为服务,供别人调用的全过程
cxf客户端调用webservice所需jar包
用CXF作为客户端调用webService的demo:本人亲测可用,eclipse工程项目包含完整代码和完整jar包, 只要用eclipse导入项目即可,运行控制台显示success或者false字符串,说明OK。
webservice的cxf框架客户端调用所需jar包,不要删除里面的jar包,直接放在lib下。亲测可用。
springboot整合CXF发布webservice和客户端调用 项目中每个类都有详细的注释,保证都能看懂,不失为一个学习springboot整合cxf来学习webservice发布调用的好例子
Springboot整合CXF发布Web service和客户端调用(用户和密码验证)打开及用
CXF客户端调用需要的最少包,版本cxf-2.7.18.jar。其中fastjson-1.2.34.jar是非必须的
cxf调用webservice,客户端最少jar包,只需4个,告别找jar包的繁琐
1.使用Java 2.用cxf开发webservice ...客户端也需要接口类文件和pojo,和cxf客户端xml 但是没有接口的实现类,就是为了去服务端来调用的。 具体有不懂可以问我 给我发消息, 劳烦评价 ,请大家支持原创 禁止转载
java CXF客户端请求ERP SAP webservice通过用户名和密码验证功能!
使用idea创建maven项目组建spring+cxf 客户端使用idea创建java Enterprise 中的WebServices Client进行创建
cxf_axis_xfire客户端调用的几种方法[收集].pdf
CXF实例源代码 客户端调用 web service 入门教程
cxf_axis_xfire客户端调用的几种方法.docx
带详细解决方案说明文档,提供三种解决方式,另外包含stax2-api.jar,stax2-api-source.jar,woodstox-core-asl-4.4.1.jar,stax-ex.jar,wstx-asl-3.2.9.jar等jar文件,亲测有效。
这个代码例子是为了调用CXF提供的WS服务,所以先要下载“CXF和Spring结合的例子”,并将服务器(tomcat)运行起来,在利用本客户端测试,本客户端是根据服务端发布的WSDL文件,用wsdl2java直接生成java代码,加入到...