请教一个最初级的webservice问题
我的开发环境是eclipse3.2+tomcat5
出现的错误是The AXIS engine could not find a target service to invoke! targetService is ITest
我的web Service是选的start service级,勾了Publish the Web Service
发布的是类ITest的hello(string name)方法
package com.tomato;
public class ITest {
public String hello(String name){
return name+ " : Hello World ";
}
}
----------------------------------
生成wsdl时没发生错误
ITest.wsdl
<?xml version= "1.0 " encoding= "UTF-8 "?>
<wsdl:definitions targetNamespace= "http://tomato.com " xmlns:apachesoap= "http://xml.apache.org/xml-soap " xmlns:impl= "http://tomato.com " xmlns:intf= "http://tomato.com " xmlns:wsdl= "http://schemas.xmlsoap.org/wsdl/ " xmlns:wsdlsoap= "http://schemas.xmlsoap.org/wsdl/soap/ " xmlns:xsd= "http://www.w3.org/2001/XMLSchema ">
<!--WSDL created by Apache Axis version: 1.3
Built on Oct 05, 2005 (05:23:37 EDT)-->
<wsdl:types>
<schema elementFormDefault= "qualified " targetNamespace= "http://tomato.com " xmlns= "http://www.w3.org/2001/XMLSchema ">
<element name= "hello ">
<complexType>
<sequence>
<element name= "in0 " type= "xsd:string "/>
</sequence>
</complexType>
</element>
<element name= "helloResponse ">
<complexType>
<sequence>
<element name= "helloReturn " type= "xsd:string "/>
</sequence>
</complexType>
</element>
</schema>
</wsdl:types>
<wsdl:message name= "helloResponse ">
<wsdl:part element= "impl:helloResponse " name= "parameters "/>
</wsdl:message>
<wsdl:message name= "helloRequest ">
<wsdl:part element= "impl:hello " name= "parameters "/>
</wsdl:message>
<wsdl:portType name= "ITest ">
<wsdl:operation name= "hello ">
<wsdl:input message= "impl:helloRequest " name= "helloRequest "/>
<wsdl:output message= "impl:helloResponse " name= "helloResponse "/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name= "ITestSoapBinding " type= "impl:ITest ">
<wsdlsoap:binding style= "document " transport= "http://schemas.xmlsoap.org/soap/http "/>
<wsdl:operation name= "hello ">
<wsdlsoap:operation soapAction= " "/>
<wsdl:input name= "helloRequest ">
<wsdlsoap:body use= "literal "/>
</wsdl:input>
<wsdl:output name= "helloResponse ">
<wsdlsoap:body use= "literal "/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name= "ITestService ">
<wsdl:port binding= "impl:ITestSoapBinding " name= "ITest ">
<wsdlsoap:address location= "http://localhost:8181/testServer/services/ITest "/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
然后用export-> war file,在tomcat的manager页面将他deploy
用http://127.0.0.1:8181/testServer/wsdl/ITest.wsdl访问正常
----------------------------------
Web Service Client
Service defintion: http://127.0.0.1:8181/testServer/wsdl/ITest.wsdl
生ITest,ITestProxy,ITestService,ITestServiceLocator,ITestSoapBindingStub类时也没有报错
写的调用方法是:
import javax.xml.rpc.ServiceException;
public class TestMain {
public static void main(String[] args) throws ServiceException, RemoteException {
// TODO Auto-generated method stub
ITest test = null;
ITestService ts = new ITestServiceLocator();
test = ts.getITest();
String words = test.hello( "zq ");
System.out.println(words);
}
}
发现调用test.hello( "zq ")就出错,但调用test.toString()没错,提示
The AXIS engine could not find a target service to invoke! targetService is ITest
请教各位高手,如何解决,我已用baidu,google,yahoo,sogou搜过了都没提具体如何解决!拜托了各位!只要提建议就有分!!
[解决办法]
server-config.wsdd 和 web.xml 这两文件是不是有哪里没配置正确。