今天写了个Axis2的例子,如下:
service类:
public class FanServiceWork {
public String SayHello(String uname){
return "Hello "+uname;
}
public int multiplication(int num1,int num2){
return num1*num2;
}
public int div(int num1,int num2){
return num1/num2;
}}service.xml内容如下:
<service name="Fanservice">
<description>
This is a my Web Service.
</description>
<parameter name="ServiceClass" locked="false">
com.FanServiceWork
</parameter>
<operation name="SayHello">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
</service>
把他发布到tomcat下面显示如下:
Available services
Fanservice
Service EPR : http://127.0.0.1:8080/axis2/services/Fanservice
Service REST epr : http://127.0.0.1:8080/axis2/rest/Fanservice 我点击Fanservice链接,居然报以下错误:
- <error>
<description>Unable to generate WSDL for this service</description>
<reason>If you wish Axis2 to automatically generate the WSDL, then please use one of the RPC message receivers for the service(s)/operation(s) in services.xml. If you have added a custom WSDL in the META-INF directory, then please make sure that the name of the service in services.xml (/serviceGroup/service/@name) is the same as in the custom wsdl's service name (/wsdl:definitions/wsdl:service/@name).</reason>
</error>请高人帮忙,是在是想不出哪里错了,试了义早上!
service类:
public class FanServiceWork {
public String SayHello(String uname){
return "Hello "+uname;
}
public int multiplication(int num1,int num2){
return num1*num2;
}
public int div(int num1,int num2){
return num1/num2;
}}service.xml内容如下:
<service name="Fanservice">
<description>
This is a my Web Service.
</description>
<parameter name="ServiceClass" locked="false">
com.FanServiceWork
</parameter>
<operation name="SayHello">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
</service>
把他发布到tomcat下面显示如下:
Available services
Fanservice
Service EPR : http://127.0.0.1:8080/axis2/services/Fanservice
Service REST epr : http://127.0.0.1:8080/axis2/rest/Fanservice 我点击Fanservice链接,居然报以下错误:
- <error>
<description>Unable to generate WSDL for this service</description>
<reason>If you wish Axis2 to automatically generate the WSDL, then please use one of the RPC message receivers for the service(s)/operation(s) in services.xml. If you have added a custom WSDL in the META-INF directory, then please make sure that the name of the service in services.xml (/serviceGroup/service/@name) is the same as in the custom wsdl's service name (/wsdl:definitions/wsdl:service/@name).</reason>
</error>请高人帮忙,是在是想不出哪里错了,试了义早上!
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<globalConfiguration>
<parameter name="adminPassword" value="admin"/>
<parameter name="attachments.Directory" value="D:\wade\software\Tomcat\webApps\WebServiceTest\WEB-INF\attachments"/>
<parameter name="attachments.implementation" value="org.apache.axis.attachments.AttachmentsImpl"/>
<parameter name="sendXsiTypes" value="true"/>
<parameter name="sendMultiRefs" value="true"/>
<parameter name="sendXMLDeclaration" value="true"/>
<parameter name="axis.sendMinimizedElements" value="true"/>
<requestFlow>
<handler type="java:org.apache.axis.handlers.JWSHandler">
<parameter name="scope" value="session"/>
</handler>
<handler type="java:org.apache.axis.handlers.JWSHandler">
<parameter name="scope" value="request"/>
<parameter name="extension" value=".jwr"/>
</handler>
</requestFlow>
</globalConfiguration>
<handler name="LocalResponder" type="java:org.apache.axis.transport.local.LocalResponder"/>
<handler name="Authenticate" type="java:org.apache.axis.handlers.SimpleAuthenticationHandler"/>
<handler name="URLMapper" type="java:org.apache.axis.handlers.http.URLMapper"/>
<service name="Hello" provider="java:RPC">
<parameter name="allowedMethods" value="*"/>
<parameter name="className" value="com.zhangq.webservice.Hello"/>
</service>
<service name="AdminService" provider="java:MSG">
<parameter name="allowedMethods" value="AdminService"/>
<parameter name="enableRemoteAdmin" value="false"/>
<parameter name="className" value="org.apache.axis.utils.Admin"/>
<namespace>http://xml.apache.org/axis/wsdd/</namespace>
</service>
<beanMapping languageSpecificType="java:com.zhangq.webservice.Pet" qname="ns1:Pet"
xmlns:ns1="urn:BeanService"/>
<transport name="local">
<responseFlow>
<handler type="LocalResponder"/>
</responseFlow>
</transport>
<transport name="http">
<requestFlow>
<handler type="URLMapper"/>
<handler type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/>
</requestFlow>
</transport>
</deployment>
把这个文件中的相关部分,替换成你的类和方法名等。试试 我的ws是成功的