Java代码
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-core</artifactId>
- <version>2.2.4</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-transports-http</artifactId>
- <version>2.2.4</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-databinding-aegis</artifactId>
- <version>2.2.4</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>2.2.4</version>
- </dependency>
- <dependency>
- <groupId>commons-httpclient</groupId>
- <artifactId>commons-httpclient</artifactId>
- <version>3.1</version>
- </dependency>
Java代码
- <wsdl:definitions xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://tempuri.org/">
- <wsdl:types>
- <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
- <s:element name="AddUser">
- <s:complexType>
- <s:sequence>
- <s:element minOccurs="1" maxOccurs="1" name="name" type="s:string"/>
- <s:element minOccurs="1" maxOccurs="1" name="password" type="s:string"/>
- </s:sequence>
- </s:complexType>
- </s:element>
- <s:element name="AddUserResponse">
- <s:complexType>
- <s:sequence>
- <s:element minOccurs="1" maxOccurs="1" name="AddUserResult" type="s:int"/>
- </s:sequence>
- </s:complexType>
- </s:element>
- </s:schema>
- </wsdl:types>
- ...
- </wsdl:definitions>
Java代码
- package com.test.ws;
- import javax.jws.WebMethod;
- import javax.jws.WebParam;
- import javax.jws.WebResult;
- import javax.jws.WebService;
- ( targetNamespace="http://tempuri.org/" )
- public interface TestService {
- @WebMethod(operationName="AddUser")
- @WebResult(targetNamespace="http://tempuri.org/",name=AddOrderResult" )
- public int addUser(
- @WebParam(name="name",targetNamespace="http://tempuri.org/")String name,
- @WebParam(name="password",targetNamespace="http://tempuri.org/")String password);
- }
Java代码
- <bean id="testService" class="com.test.ws.TestService"
- factory-bean="clientFactory" factory-method="create"/>
- <bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
- <property name="serviceClass" value="com.test.ws.TestService"/>
- <property name="address" value="http://192.168.1.101/Service/TestService.asmx"/>
- <property name="bindingId" value="http://schemas.xmlsoap.org/wsdl/soap12/"/>
- </bean>