高分求救wsdl2java 如何生成服务器端代码?
求救。别人给了我一个.wsdl文件,通过该文件让我写服务器端的代码。如何通过wsdl2java 生成服务器端代码?以及实现哪个一个接口。小弟用的是windows系统。。
[解决办法]
wsdl文件为如下。
<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions targetNamespace="http://esmp.enterprise.com/service/ASPSubNotifactionService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://esmp.enterprise.com/service/ASPSubNotifactionService" xmlns:intf="http://esmp.enterprise.com/service/ASPSubNotifactionService" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="urn:ASPSubNotifactionService" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<schema targetNamespace="http://esmp.enterprise.com/service/ASPSubNotifactionService" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
<complexType name="ASPSubNotificationRequest">
<sequence>
<element name="aspID" type="soapenc:string" />
<element name="transactionID" type="soapenc:string" />
<element name="subscriptionID" nillable="true" type="soapenc:string" />
<element name="sentTime" type="soapenc:string" />
<element name="resultCode" type="xsd:int" />
<element name="resultMessage" nillable="true" type="soapenc:string" />
</sequence>
</complexType>
<complexType name="ASPProvisionResultNotificationResponse">
<sequence>
<element name="aspID" type="soapenc:string" />
<element name="sentTime" type="soapenc:string" />
<element name="transactionID" type="soapenc:string" />
<element name="subscriptionID" nillable="true" type="soapenc:string" />
<element name="resultCode" type="xsd:int" />
<element name="resultMessage" nillable="true" type="soapenc:string" />
</sequence>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="ASPSubNotificationRequestResponse">
<wsdl:part name="ASPSubNotificationRequestReturn" type="tns1:ASPProvisionResultNotificationResponse" />
</wsdl:message>
<wsdl:message name="ASPSubNotificationRequestRequest">
<wsdl:part name="requestType" type="tns1:ASPSubNotificationRequest" />
</wsdl:message>
<wsdl:portType name="ASPSubNotificationRequestService">
<wsdl:operation name="ASPSubNotificationRequest" parameterOrder="requestType">
<wsdl:input message="impl:ASPSubNotificationRequestRequest" name="ASPSubNotificationRequestRequest" />
<wsdl:output message="impl:ASPSubNotificationRequestResponse" name="ASPSubNotificationRequestResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ASPSubNotifactionServiceSoapBinding" type="impl:ASPSubNotificationRequestService">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="ASPSubNotificationRequest">
<wsdlsoap:operation soapAction="" />
<wsdl:input name="ASPSubNotificationRequestRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://ASPSubNotifactionService.service.services.webservices.esmp.ericsson.com" use="encoded" />
</wsdl:input>
<wsdl:output name="ASPSubNotificationRequestResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://esmp.enterprise.com/service/ASPSubNotifactionService" use="encoded" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ASPSubNotifactionServiceService">
<wsdl:port binding="impl:ASPSubNotifactionServiceSoapBinding" name="ASPSubNotifactionService">
<wsdlsoap:address location="http://esmp.enterprise.com//service/ASPSubNotifactionService" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
在eclipse中显示
<wsdl:message name="ASPSubNotificationRequestResponse">
<wsdl:part name="ASPSubNotificationRequestReturn"
type="tns1:ASPProvisionResultNotificationResponse" />
</wsdl:message>
<wsdl:message name="ASPSubNotificationRequestRequest">
<wsdl:part name="requestType"
type="tns1:ASPSubNotificationRequest" />
</wsdl:message>
中的type类型不正确。
[解决办法]
>>如何通过wsdl2java 生成服务器端代码
没用过,帮你顶一下
[解决办法]
按有几个群,你不妨加进去,可以和大家一起讨论啊.........46986340,28039577,4804620
在那里看看有无能回答你的,谢谢,LZ,甭忘了给俺分哦,谢谢LZ
[解决办法]
帮顶!
[解决办法]
学习
[解决办法]
什么叫wsdl文件,是用什么工具生成的,作用是什么?能解释一下吗?谢谢LZ
[解决办法]
这个应该算soap的一项应该吧?我也不是很熟,以前参照一个BLOG做过一个小的测试:http://blog.csdn.net/yown/archive/2006/07/03/869523.aspx
你可以看看
接口调用方法(java实现)
假设提供soap接口的服务端地址为” http://192.168.13.1:8088/test”
访问WEB地址” http://10.0.0.100:8088/test?wsdl”获得wsdl文档
假定文档中说明该调用接口的类方法String do(String msg)
try {
String endpoint = " http://192.168.13.1:8088/test";
org.apache.axis.client.Service service = new org.apache.axis.client.Service();
org.apache.axis.client.Call call = null;
call = (org.apache.axis.client.Call) service.createCall();
call.setOperationName(new javax.xml.namespace.QName(endpoint,"do"));
call.setTargetEndpointAddress(new java.net.URL(endpoint));
String msg = “testParameter”;
String ret = (String)call.invoke(new Object[]{msg});
}
catch (ServiceException ex)
{
ex.printStackTrace();
}
[解决办法]
把wsdl转换成java有很多工具
比如axis的WSDL2JAVA类就可以,
java -cp axis.jar;commons-discovery-0.2.jar;commons-logging-1.0.4.jar;jaxrpc.jar;log4j-1.2.8.jar;saaj.jar;wsdl4j-1.5.1.jar org.apache.axis.wsdl.WSDL2Java 你要转换的WSDL.wsdl
如果直接使用上边的命令的话,依赖文件必须和wsdl文件在同一个目录下
[解决办法]
LS说的不错。如果你用eclipse开发的话,可以试试Axis2 Code Generator插件,使用非常方便。
下载地址:http://mirror.x10.com/mirror/apache/ws/axis2/tools/1_3/axis2-eclipse-codegen-wizard.zip