- 浏览: 29524 次
- 性别:
最近访客 更多访客>>
文章分类
最新评论
-
Just-Do-it:
no1dog 写道3、 结构化程序设计主要强调的是()。
A、 ...
XX软件工程师笔试试题 -
no1dog:
3、 结构化程序设计主要强调的是()。A、 程序的规模 B、 ...
XX软件工程师笔试试题 -
kingpeixin:
<bean id="empServiceImp ...
Spring自动装配模式之:byName的解析
通过wsdl生成服务和客户端代码
1. wsdl文件
D:\axis151\mysamples\sample1
axis2userguide.wsdl
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="http://apache.org/axis2/Axis2UserGuide"
xmlns:intf="http://apache.org/axis2/Axis2UserGuide"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://apache.org/axis2/Axis2UserGuide">
<wsdl:types>
<schema
elementFormDefault="qualified"
targetNamespace="http://apache.org/axis2/Axis2UserGuide"
xmlns="http://www.w3.org/2001/XMLSchema">
<!-- ELEMENTS -->
<element name="DoInOnlyRequest">
<complexType>
<sequence>
<element name="messageString" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="TwoWayOneParameterEchoRequest">
<complexType>
<sequence>
<element name="echoString" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="TwoWayOneParameterEchoResponse">
<complexType>
<sequence>
<element name="echoString" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="NoParametersRequest">
<complexType/>
</element>
<element name="NoParametersResponse">
<complexType/>
</element>
<element name="MultipleParametersAddItemRequest">
<complexType>
<sequence>
<element name="itemId" type="xsd:int"/>
<element name="itemName" type="xsd:string"/>
<element name="price" type="xsd:float"/>
<element name="description" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="MultipleParametersAddItemResponse">
<complexType>
<sequence>
<element name="itemId" type="xsd:int"/>
<element name="successfulAdd" type="xsd:boolean"/>
</sequence>
</complexType>
</element>
</schema>
</wsdl:types>
<!-- MESSAGES -->
<wsdl:message name="DoInOnlyRequestMessage">
<wsdl:part name="input" element="impl:DoInOnlyRequest"/>
</wsdl:message>
<wsdl:message name="TwoWayOneParameterEchoRequestMessage">
<wsdl:part name="input" element="impl:TwoWayOneParameterEchoRequest"/>
</wsdl:message>
<wsdl:message name="TwoWayOneParameterEchoResponseMessage">
<wsdl:part name="output" element="impl:TwoWayOneParameterEchoResponse"/>
</wsdl:message>
<wsdl:message name="NoParametersRequestMessage">
<wsdl:part name="input" element="impl:NoParametersRequest"/>
</wsdl:message>
<wsdl:message name="NoParametersResponseMessage">
<wsdl:part name="output" element="impl:NoParametersResponse"/>
</wsdl:message>
<wsdl:message name="MultipleParametersAddItemRequestMessage">
<wsdl:part name="input" element="impl:MultipleParametersAddItemRequest"/>
</wsdl:message>
<wsdl:message name="MultipleParametersAddItemResponseMessage">
<wsdl:part name="output" element="impl:MultipleParametersAddItemResponse"/>
</wsdl:message>
<!-- Port type (operations) -->
<wsdl:portType name="Axis2UserGuidePortType">
<wsdl:operation name="DoInOnly" parameterOrder="input">
<wsdl:input name="DoInOnlyRequestMessage"
message="impl:DoInOnlyRequestMessage"/>
</wsdl:operation>
<wsdl:operation name="TwoWayOneParameterEcho" parameterOrder="input">
<wsdl:input name="TwoWayOneParameterEchoRequestMessage"
message="impl:TwoWayOneParameterEchoRequestMessage"/>
<wsdl:output name="TwoWayOneParameterEchoResponseMessage"
message="impl:TwoWayOneParameterEchoResponseMessage"/>
</wsdl:operation>
<wsdl:operation name="NoParameters" parameterOrder="input">
<wsdl:input name="NoParametersRequestMessage"
message="impl:NoParametersRequestMessage"/>
<wsdl:output name="NoParametersResponseMessage"
message="impl:NoParametersResponseMessage"/>
</wsdl:operation>
<wsdl:operation name="MultipleParametersAddItem" parameterOrder="input">
<wsdl:input name="MultipleParametersAddItemRequestMessage"
message="impl:MultipleParametersAddItemRequestMessage"/>
<wsdl:output name="MultipleParametersAddItemResponseMessage"
message="impl:MultipleParametersAddItemResponseMessage"/>
</wsdl:operation>
</wsdl:portType>
<!-- BINDING (bind operations) -->
<wsdl:binding
name="Axis2UserGuideSoapBinding"
type="impl:Axis2UserGuidePortType">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="DoInOnly">
<wsdlsoap:operation soapAction="DoInOnly"/>
<wsdl:input>
<wsdlsoap:body use="literal"/>
</wsdl:input>
</wsdl:operation>
<wsdl:operation name="TwoWayOneParameterEcho">
<wsdlsoap:operation soapAction="TwoWayOneParameterEcho"/>
<wsdl:input>
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="NoParameters">
<wsdlsoap:operation soapAction="NoParameters"/>
<wsdl:input>
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="MultipleParametersAddItem">
<wsdlsoap:operation soapAction="MultipleParametersAddItem"/>
<wsdl:input>
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<!-- SERVICE -->
<wsdl:service name="Axis2UserGuideService">
<wsdl:port binding="impl:Axis2UserGuideSoapBinding"
name="Axis2UserGuide">
<wsdlsoap:address location="http://localhost/axis2/services/Axis2UserGuide"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
2. 生成service代码
step1: generating service source code by wsdl
command line:
D:\axis151\mysamples\sample1\wsdl2java.bat -uri file:///D:/axis151/mysamples/sample1/Axis2UserGuide.wsdl
-p org.apache.axis2.axis2userguide -o target_directory_name -d adb -s -wv 1.5.1 -ss -sd
result:
D:\axis151\mysamples\sample1\src\org\apache\axis2\axis2userguide\*.java(服务端代码)
D:\axis151\mysamples\sample1\resource\services.xml, Axis2UserGuideService.wsdl
(可以用远程地址实现,在下文中有介绍)
修改 Axis2UserGuideServiceSkeleton.java,在每个方法中填写入需要运行的代码(粗体字部分为添加的代码示例)
package org.apache.axis2.axis2userguide;
public class Axis2UserGuideServiceSkeleton{
public org.apache.axis2.axis2userguide.NoParametersResponse noParameters
(
org.apache.axis2.axis2userguide.NoParametersRequest noParametersRequest
)
{
System.out.println(noParametersRequest);
NoParametersResponse res = new NoParametersResponse();
return res;
//TODO : fill this with the necessary business logic
//throw new java.lang.UnsupportedOperationException("Please implement " + this.getClass().getName() + "#noParameters");
}
public void doInOnly
(
org.apache.axis2.axis2userguide.DoInOnlyRequest doInOnlyRequest
)
{
//TODO : fill this with the necessary business logic
System.out.println(doInOnlyRequest.getMessageString());
}
public org.apache.axis2.axis2userguide.MultipleParametersAddItemResponse multipleParametersAddItem
(
org.apache.axis2.axis2userguide.MultipleParametersAddItemRequest multipleParametersAddItemRequest
)
{
//TODO : fill this with the necessary business logic
System.out.println(multipleParametersAddItemRequest.getPrice());
System.out.println(multipleParametersAddItemRequest.getItemId());
System.out.println(multipleParametersAddItemRequest.getDescription());
System.out.println(multipleParametersAddItemRequest.getItemName());
MultipleParametersAddItemResponse res =
new MultipleParametersAddItemResponse();
res.setSuccessfulAdd(true);
res.setItemId(multipleParametersAddItemRequest.getItemId());
return res;
//throw new java.lang.UnsupportedOperationException("Please implement " + this.getClass().getName() + "#multipleParametersAddItem");
}
public org.apache.axis2.axis2userguide.TwoWayOneParameterEchoResponse twoWayOneParameterEcho
(
org.apache.axis2.axis2userguide.TwoWayOneParameterEchoRequest twoWayOneParameterEchoRequest
)
{
//TODO : fill this with the necessary business logic
System.out.println(twoWayOneParameterEchoRequest.getEchoString());
TwoWayOneParameterEchoResponse res =
new TwoWayOneParameterEchoResponse();
res.setEchoString(twoWayOneParameterEchoRequest.getEchoString());
return res;
//throw new java.lang.UnsupportedOperationException("Please implement " + this.getClass().getName() + "#twoWayOneParameterEcho");
}
}
3. 生成client代码
步骤1: command line:
D:\axis151\mysamples\sample1\WSDL2Java -uri Axis2UserGuide.wsdl -p org.apache.axis2.axis2userguide -d adb -s
result:
D:\axis151\mysamples\sample1\src\org.apache.axis2.axis2userguide.Axis2UserGuideServiceStub.java
D:\axis151\mysamples\sample1\build.xml
步骤2:写一个使用Axis2UserGuideServiceStub.java的客户端服务代码
Client.java
package org.apache.axis2.axis2userguide;
import org.apache.axis2.axis2userguide.Axis2UserGuideServiceStub.DoInOnlyRequest;
import org.apache.axis2.axis2userguide.Axis2UserGuideServiceStub.TwoWayOneParameterEchoRequest;
import org.apache.axis2.axis2userguide.Axis2UserGuideServiceStub.NoParametersRequest;
import org.apache.axis2.axis2userguide.Axis2UserGuideServiceStub.MultipleParametersAddItemRequest;
import org.apache.axis2.axis2userguide.Axis2UserGuideServiceStub.TwoWayOneParameterEchoResponse;
import org.apache.axis2.axis2userguide.Axis2UserGuideServiceStub.NoParametersResponse;
import org.apache.axis2.axis2userguide.Axis2UserGuideServiceStub.MultipleParametersAddItemResponse;
public class Client{
public static void main(java.lang.String args[]){
try{
Axis2UserGuideServiceStub stub =
new Axis2UserGuideServiceStub
("http://localhost/axis2/services/Axis2UserGuideService");
doInOnly(stub);
twoWayOneParameterEcho(stub);
noParameters(stub);
multipleParameters(stub);
} catch(Exception e){
e.printStackTrace();
System.out.println("\n\n\n");
}
}
public static void doInOnly(Axis2UserGuideServiceStub stub){
try{
DoInOnlyRequest req = new DoInOnlyRequest();
req.setMessageString("An in only request");
stub.doInOnly(req);
System.out.println("done");
} catch(Exception e){
e.printStackTrace();
System.out.println("\n\n\n");
}
}
public static void twoWayOneParameterEcho(Axis2UserGuideServiceStub stub){
try{
TwoWayOneParameterEchoRequest req = new TwoWayOneParameterEchoRequest();
req.setEchoString("echo! ... echo!");
TwoWayOneParameterEchoResponse res =
stub.twoWayOneParameterEcho(req);
System.out.println(res.getEchoString());
} catch(Exception e){
e.printStackTrace();
System.out.println("\n\n\n");
}
}
public static void noParameters(Axis2UserGuideServiceStub stub){
try{
NoParametersRequest req = new NoParametersRequest();
System.out.println(stub.noParameters(req));
} catch(Exception e){
e.printStackTrace();
System.out.println("\n\n\n");
}
}
public static void multipleParameters(Axis2UserGuideServiceStub stub){
try{
MultipleParametersAddItemRequest req =
new MultipleParametersAddItemRequest();
req.setPrice((float)1.99);
req.setItemId((int)23872983);
req.setDescription("Must have for cooking");
req.setItemName("flour");
MultipleParametersAddItemResponse res =
stub.multipleParametersAddItem(req);
System.out.println(res.getSuccessfulAdd());
System.out.println(res.getItemId());
} catch(Exception e){
e.printStackTrace();
System.out.println("\n\n\n");
}
}
}
4. 部署及测试
1) 生成service
D:\axis151\mysamples\sample1\ant jar.server
复制以上生成的 .aar file to %tomcat_home%/webapps/axis2/web-inf/services/
2) 生成client
D:\axis151\mysamples\sample1\ant jar.client
3) 部署及测试
在自动生成的build.xml中增加一段测试代码
<target if="jars.ok" name="run.client">
<java classname="org.apache.axis2.axis2userguide.Client">
<classpath refid="client.class.path" />
</java>
<path id="client.class.path">
<pathelement location="${lib}/${name}-test-client.jar"/>
<path refid="axis2.class.path"/>
<pathelement location="${classes}"/>
</path>
</target>
D:\axis151\mysamples\sample1\ant run.client
1. wsdl文件
D:\axis151\mysamples\sample1
axis2userguide.wsdl
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="http://apache.org/axis2/Axis2UserGuide"
xmlns:intf="http://apache.org/axis2/Axis2UserGuide"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://apache.org/axis2/Axis2UserGuide">
<wsdl:types>
<schema
elementFormDefault="qualified"
targetNamespace="http://apache.org/axis2/Axis2UserGuide"
xmlns="http://www.w3.org/2001/XMLSchema">
<!-- ELEMENTS -->
<element name="DoInOnlyRequest">
<complexType>
<sequence>
<element name="messageString" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="TwoWayOneParameterEchoRequest">
<complexType>
<sequence>
<element name="echoString" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="TwoWayOneParameterEchoResponse">
<complexType>
<sequence>
<element name="echoString" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="NoParametersRequest">
<complexType/>
</element>
<element name="NoParametersResponse">
<complexType/>
</element>
<element name="MultipleParametersAddItemRequest">
<complexType>
<sequence>
<element name="itemId" type="xsd:int"/>
<element name="itemName" type="xsd:string"/>
<element name="price" type="xsd:float"/>
<element name="description" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="MultipleParametersAddItemResponse">
<complexType>
<sequence>
<element name="itemId" type="xsd:int"/>
<element name="successfulAdd" type="xsd:boolean"/>
</sequence>
</complexType>
</element>
</schema>
</wsdl:types>
<!-- MESSAGES -->
<wsdl:message name="DoInOnlyRequestMessage">
<wsdl:part name="input" element="impl:DoInOnlyRequest"/>
</wsdl:message>
<wsdl:message name="TwoWayOneParameterEchoRequestMessage">
<wsdl:part name="input" element="impl:TwoWayOneParameterEchoRequest"/>
</wsdl:message>
<wsdl:message name="TwoWayOneParameterEchoResponseMessage">
<wsdl:part name="output" element="impl:TwoWayOneParameterEchoResponse"/>
</wsdl:message>
<wsdl:message name="NoParametersRequestMessage">
<wsdl:part name="input" element="impl:NoParametersRequest"/>
</wsdl:message>
<wsdl:message name="NoParametersResponseMessage">
<wsdl:part name="output" element="impl:NoParametersResponse"/>
</wsdl:message>
<wsdl:message name="MultipleParametersAddItemRequestMessage">
<wsdl:part name="input" element="impl:MultipleParametersAddItemRequest"/>
</wsdl:message>
<wsdl:message name="MultipleParametersAddItemResponseMessage">
<wsdl:part name="output" element="impl:MultipleParametersAddItemResponse"/>
</wsdl:message>
<!-- Port type (operations) -->
<wsdl:portType name="Axis2UserGuidePortType">
<wsdl:operation name="DoInOnly" parameterOrder="input">
<wsdl:input name="DoInOnlyRequestMessage"
message="impl:DoInOnlyRequestMessage"/>
</wsdl:operation>
<wsdl:operation name="TwoWayOneParameterEcho" parameterOrder="input">
<wsdl:input name="TwoWayOneParameterEchoRequestMessage"
message="impl:TwoWayOneParameterEchoRequestMessage"/>
<wsdl:output name="TwoWayOneParameterEchoResponseMessage"
message="impl:TwoWayOneParameterEchoResponseMessage"/>
</wsdl:operation>
<wsdl:operation name="NoParameters" parameterOrder="input">
<wsdl:input name="NoParametersRequestMessage"
message="impl:NoParametersRequestMessage"/>
<wsdl:output name="NoParametersResponseMessage"
message="impl:NoParametersResponseMessage"/>
</wsdl:operation>
<wsdl:operation name="MultipleParametersAddItem" parameterOrder="input">
<wsdl:input name="MultipleParametersAddItemRequestMessage"
message="impl:MultipleParametersAddItemRequestMessage"/>
<wsdl:output name="MultipleParametersAddItemResponseMessage"
message="impl:MultipleParametersAddItemResponseMessage"/>
</wsdl:operation>
</wsdl:portType>
<!-- BINDING (bind operations) -->
<wsdl:binding
name="Axis2UserGuideSoapBinding"
type="impl:Axis2UserGuidePortType">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="DoInOnly">
<wsdlsoap:operation soapAction="DoInOnly"/>
<wsdl:input>
<wsdlsoap:body use="literal"/>
</wsdl:input>
</wsdl:operation>
<wsdl:operation name="TwoWayOneParameterEcho">
<wsdlsoap:operation soapAction="TwoWayOneParameterEcho"/>
<wsdl:input>
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="NoParameters">
<wsdlsoap:operation soapAction="NoParameters"/>
<wsdl:input>
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="MultipleParametersAddItem">
<wsdlsoap:operation soapAction="MultipleParametersAddItem"/>
<wsdl:input>
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<!-- SERVICE -->
<wsdl:service name="Axis2UserGuideService">
<wsdl:port binding="impl:Axis2UserGuideSoapBinding"
name="Axis2UserGuide">
<wsdlsoap:address location="http://localhost/axis2/services/Axis2UserGuide"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
2. 生成service代码
step1: generating service source code by wsdl
command line:
D:\axis151\mysamples\sample1\wsdl2java.bat -uri file:///D:/axis151/mysamples/sample1/Axis2UserGuide.wsdl
-p org.apache.axis2.axis2userguide -o target_directory_name -d adb -s -wv 1.5.1 -ss -sd
result:
D:\axis151\mysamples\sample1\src\org\apache\axis2\axis2userguide\*.java(服务端代码)
D:\axis151\mysamples\sample1\resource\services.xml, Axis2UserGuideService.wsdl
(可以用远程地址实现,在下文中有介绍)
修改 Axis2UserGuideServiceSkeleton.java,在每个方法中填写入需要运行的代码(粗体字部分为添加的代码示例)
package org.apache.axis2.axis2userguide;
public class Axis2UserGuideServiceSkeleton{
public org.apache.axis2.axis2userguide.NoParametersResponse noParameters
(
org.apache.axis2.axis2userguide.NoParametersRequest noParametersRequest
)
{
System.out.println(noParametersRequest);
NoParametersResponse res = new NoParametersResponse();
return res;
//TODO : fill this with the necessary business logic
//throw new java.lang.UnsupportedOperationException("Please implement " + this.getClass().getName() + "#noParameters");
}
public void doInOnly
(
org.apache.axis2.axis2userguide.DoInOnlyRequest doInOnlyRequest
)
{
//TODO : fill this with the necessary business logic
System.out.println(doInOnlyRequest.getMessageString());
}
public org.apache.axis2.axis2userguide.MultipleParametersAddItemResponse multipleParametersAddItem
(
org.apache.axis2.axis2userguide.MultipleParametersAddItemRequest multipleParametersAddItemRequest
)
{
//TODO : fill this with the necessary business logic
System.out.println(multipleParametersAddItemRequest.getPrice());
System.out.println(multipleParametersAddItemRequest.getItemId());
System.out.println(multipleParametersAddItemRequest.getDescription());
System.out.println(multipleParametersAddItemRequest.getItemName());
MultipleParametersAddItemResponse res =
new MultipleParametersAddItemResponse();
res.setSuccessfulAdd(true);
res.setItemId(multipleParametersAddItemRequest.getItemId());
return res;
//throw new java.lang.UnsupportedOperationException("Please implement " + this.getClass().getName() + "#multipleParametersAddItem");
}
public org.apache.axis2.axis2userguide.TwoWayOneParameterEchoResponse twoWayOneParameterEcho
(
org.apache.axis2.axis2userguide.TwoWayOneParameterEchoRequest twoWayOneParameterEchoRequest
)
{
//TODO : fill this with the necessary business logic
System.out.println(twoWayOneParameterEchoRequest.getEchoString());
TwoWayOneParameterEchoResponse res =
new TwoWayOneParameterEchoResponse();
res.setEchoString(twoWayOneParameterEchoRequest.getEchoString());
return res;
//throw new java.lang.UnsupportedOperationException("Please implement " + this.getClass().getName() + "#twoWayOneParameterEcho");
}
}
3. 生成client代码
步骤1: command line:
D:\axis151\mysamples\sample1\WSDL2Java -uri Axis2UserGuide.wsdl -p org.apache.axis2.axis2userguide -d adb -s
result:
D:\axis151\mysamples\sample1\src\org.apache.axis2.axis2userguide.Axis2UserGuideServiceStub.java
D:\axis151\mysamples\sample1\build.xml
步骤2:写一个使用Axis2UserGuideServiceStub.java的客户端服务代码
Client.java
package org.apache.axis2.axis2userguide;
import org.apache.axis2.axis2userguide.Axis2UserGuideServiceStub.DoInOnlyRequest;
import org.apache.axis2.axis2userguide.Axis2UserGuideServiceStub.TwoWayOneParameterEchoRequest;
import org.apache.axis2.axis2userguide.Axis2UserGuideServiceStub.NoParametersRequest;
import org.apache.axis2.axis2userguide.Axis2UserGuideServiceStub.MultipleParametersAddItemRequest;
import org.apache.axis2.axis2userguide.Axis2UserGuideServiceStub.TwoWayOneParameterEchoResponse;
import org.apache.axis2.axis2userguide.Axis2UserGuideServiceStub.NoParametersResponse;
import org.apache.axis2.axis2userguide.Axis2UserGuideServiceStub.MultipleParametersAddItemResponse;
public class Client{
public static void main(java.lang.String args[]){
try{
Axis2UserGuideServiceStub stub =
new Axis2UserGuideServiceStub
("http://localhost/axis2/services/Axis2UserGuideService");
doInOnly(stub);
twoWayOneParameterEcho(stub);
noParameters(stub);
multipleParameters(stub);
} catch(Exception e){
e.printStackTrace();
System.out.println("\n\n\n");
}
}
public static void doInOnly(Axis2UserGuideServiceStub stub){
try{
DoInOnlyRequest req = new DoInOnlyRequest();
req.setMessageString("An in only request");
stub.doInOnly(req);
System.out.println("done");
} catch(Exception e){
e.printStackTrace();
System.out.println("\n\n\n");
}
}
public static void twoWayOneParameterEcho(Axis2UserGuideServiceStub stub){
try{
TwoWayOneParameterEchoRequest req = new TwoWayOneParameterEchoRequest();
req.setEchoString("echo! ... echo!");
TwoWayOneParameterEchoResponse res =
stub.twoWayOneParameterEcho(req);
System.out.println(res.getEchoString());
} catch(Exception e){
e.printStackTrace();
System.out.println("\n\n\n");
}
}
public static void noParameters(Axis2UserGuideServiceStub stub){
try{
NoParametersRequest req = new NoParametersRequest();
System.out.println(stub.noParameters(req));
} catch(Exception e){
e.printStackTrace();
System.out.println("\n\n\n");
}
}
public static void multipleParameters(Axis2UserGuideServiceStub stub){
try{
MultipleParametersAddItemRequest req =
new MultipleParametersAddItemRequest();
req.setPrice((float)1.99);
req.setItemId((int)23872983);
req.setDescription("Must have for cooking");
req.setItemName("flour");
MultipleParametersAddItemResponse res =
stub.multipleParametersAddItem(req);
System.out.println(res.getSuccessfulAdd());
System.out.println(res.getItemId());
} catch(Exception e){
e.printStackTrace();
System.out.println("\n\n\n");
}
}
}
4. 部署及测试
1) 生成service
D:\axis151\mysamples\sample1\ant jar.server
复制以上生成的 .aar file to %tomcat_home%/webapps/axis2/web-inf/services/
2) 生成client
D:\axis151\mysamples\sample1\ant jar.client
3) 部署及测试
在自动生成的build.xml中增加一段测试代码
<target if="jars.ok" name="run.client">
<java classname="org.apache.axis2.axis2userguide.Client">
<classpath refid="client.class.path" />
</java>
<path id="client.class.path">
<pathelement location="${lib}/${name}-test-client.jar"/>
<path refid="axis2.class.path"/>
<pathelement location="${classes}"/>
</path>
</target>
D:\axis151\mysamples\sample1\ant run.client
相关推荐
在给定的压缩包中,有一个名为`wsdl.exe`的文件,这很可能是一个命令行工具,用于从WSDL文件生成客户端代码。使用这个工具,开发者通常需要提供WSDL文件的URL或本地路径,然后指定输出目录,工具将自动生成对应的...
axis2根据wsdl生成java客户端代码 D:\Software\axis2-1.6.2\bin>wsdl2java.bat -uri http://10.33.30.216:9099/facs/services/ResourceSynchroWebService?wsdl -o E:\wsdloutput -p com.util wsdl2java.bat -uri ...
使用XFire根据WSDL生成客户端代码,可以大大简化开发过程,因为它自动生成了与服务接口对应的Java类和代理。以下是具体步骤: 1. **安装和配置XFire**:首先,确保已经下载并安装了XFire库。你可以通过Maven或...
4. **生成客户端代码**: 对于客户端,同样使用`soapcpp2`,但需要指定不同的选项来生成客户端代理代码: - 例如:`soapcpp2 -I . -c -S myservice.wsdl` - 这会生成客户端的`.h`和`.cpp`文件,其中包含了调用...
根据WSDL文件生成客户端代码与创建客户端工程 注意小细节:在根据对方提供的webservice地址,先将对方webservice的wsdl文件描述文件保存到本地时,格式先保存为xml,后将其后缀名为.wsdl的文件 否则报:...
步骤五:生成客户端代码 现在,我们可以生成Java客户端代码。在Eclipse中,我们可以点击“Finish”,然后Eclipse将根据wsdl文件生成Java客户端代码。 步骤六:查看客户端代码 最后,我们可以查看生成的Java客户端...
在Eclipse集成开发环境中,我们可以使用"Web Service Explorer"或"New Web Service Client"向导来根据WSDL文件生成客户端代码。以下是步骤: 1. **导入WSDL文件**:在Eclipse中,选择“File” > “Import” > “Web...
使用cxf wsdl2java生成webservice客户端命令
利用wsdl2java工具和SoapUI工具生成webservice的客户端代码 Java实现登陆验证调用 压缩包里包括需要的所有文件,供需要的同学使用 1.apache-cxf-3.3.7 2.SoapUI 5.4.0-EB 3.生成代码的教程 4.获取service调用的...
在IT行业中,WSDL(Web Services Description ...总之,WSDL客户端生成工具是Web服务开发中的得力助手,通过自动化生成客户端代码,极大地降低了开发难度。理解其工作原理和使用方法,对于高效地利用Web服务至关重要。
o%Output_Path% -p %Package% wsLvxianService.wsdl这句中的wsLvxianService.wsdl改为你的wsdl文件名,参数%Package%表示的是你的文件生成之后保存的包名,Output_Path标示的是你的输出文件路径。
本文将深入探讨如何使用MyEclipse集成开发环境来调用Axis工具,通过WSDL(Web Service Description Language)文件生成客户端代码。这个过程对于理解Web服务的生命周期和客户端开发流程至关重要。 首先,我们需要...
2. **JAX-WS**:Java API for XML Web Services,Java平台的标准,提供了wsimport工具,能够从WSDL生成客户端代码。 3. .NET Framework的`svcutil.exe`:对于.NET开发者,这个工具可以生成C#或VB.NET的客户端代码。 ...
总的来说,Axis2 1.6.2提供了一种简洁的方式,帮助开发者快速地从WSDL生成客户端代码,从而简化Web服务的使用。熟悉这一过程对于任何涉及跨系统交互的Java开发者来说都是非常有价值的技能。记住,如果在使用过程中...
5. **生成客户端代码**: 点击"OK"后,Eclipse会解析WSDL文件,并自动生成对应的Java客户端代码,包括服务代理类和服务接口等。这些代码位于新创建的包中,通常是根据WSDL命名空间自动创建的。 6. **安装客户端**...
《gSOAP:基于WSDL生成C++调用的文件详解》 gSOAP是一个开源的工具集,用于在C和C++中实现Web服务客户端和服务端。它特别适用于处理SOAP(简单对象访问协议)消息,而WSDL(Web服务描述语言)则是一种XML格式,用于...
在日常开发中,通常是由开发团队构建WebService服务端,客户端则通过服务端提供的WS-Definition Language (WSDL) 文件生成客户端代理并进行交互。但有时也会遇到特殊情况,比如与特定企业合作时,对方可能仅提供WSDL...
本篇文章将详细探讨“wsdl生成java代码工具”的相关知识点,以及如何使用这个工具。 1. **WSDL简介**: WSDL文件描述了Web服务的接口,包括服务提供的操作、输入和输出消息的格式,以及服务的位置。它使得开发者...
总之,通过Eclipse从WSDL快速生成Java客户端代码是开发Web服务应用的重要环节。这个过程简化了开发者手动编写与Web服务交互代码的复杂性,使得开发更加高效。记住,理解WSDL和Web服务的基本概念,以及如何在Eclipse...
生成客户端代码的流程相对简单: 1. **再次使用Axis工具**:这次是使用client-config.wsdd文件,生成客户端的stub类。 ```bash java org.apache.axis.client.AdminClient -url http://service_url?wsdl client-...