求助:webservice 启动报接口错误 50
本机用两个eclipse启动了webservice的服务端和客户端!客户端是用wsdl2java自动生成的当执行到java.lang.String_sayHello__r...
本机用两个eclipse 启动了webservice的服务端和客户端!客户端是用wsdl2java自动生成的 当执行到java.lang.String _sayHello__return = port.sayHello(_sayHello_arg0);(简单的helloword例子)时控制台报了如下的错误:
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Could not instantiate service class test.HelloWorld because it is an interface.
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:160)
at com.sun.proxy.$Proxy35.sayHello(Unknown Source)
at WsImpl.HelloWorld_HelloWorldPort_Client.main(HelloWorld_HelloWorldPort_Client.java:56)
Caused by: org.apache.cxf.binding.soap.SoapFault: Could not instantiate service class test.HelloWorld because it is an interface.
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.unmarshalFault(Soap11FaultInInterceptor.java:86)
----------------------------------------------------------------------------------------------------------
一下是接口和实现类的代码:
import javax.jws.WebService;
@WebService
public interface HelloWorld
{
public String sayHello(String name);
}
------
import javax.jws.WebService;
import test.HelloWorld;
@WebService(endpointInterface="test.HelloWorld",serviceName="HelloWorldWebService")
public class HelloWorldImpl implements HelloWorld
{
@Override
public String sayHello(String name)
{
System.out.println("sayHello方法被调用");
return ("Hello"+name);
}
}
真不知道哪里的错误,请高手不吝赐教!50分不要嫌少 展开
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Could not instantiate service class test.HelloWorld because it is an interface.
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:160)
at com.sun.proxy.$Proxy35.sayHello(Unknown Source)
at WsImpl.HelloWorld_HelloWorldPort_Client.main(HelloWorld_HelloWorldPort_Client.java:56)
Caused by: org.apache.cxf.binding.soap.SoapFault: Could not instantiate service class test.HelloWorld because it is an interface.
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.unmarshalFault(Soap11FaultInInterceptor.java:86)
----------------------------------------------------------------------------------------------------------
一下是接口和实现类的代码:
import javax.jws.WebService;
@WebService
public interface HelloWorld
{
public String sayHello(String name);
}
------
import javax.jws.WebService;
import test.HelloWorld;
@WebService(endpointInterface="test.HelloWorld",serviceName="HelloWorldWebService")
public class HelloWorldImpl implements HelloWorld
{
@Override
public String sayHello(String name)
{
System.out.println("sayHello方法被调用");
return ("Hello"+name);
}
}
真不知道哪里的错误,请高手不吝赐教!50分不要嫌少 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏50(财富值+成长值)
3个回答
展开全部
能正常生成客户端说明你的服务接口描述没有问题,应该是你客户端调用的代码有问题,把你客户端调用代码贴出来看看。可参考如下代码:
JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory.newInstance();
//你的wsdl地址
Client client = clientFactory.createClient("http://localhost:8080/helloWorld?wsdl");
Object[] res = client.invoke("sayHello", "chhgge");
System.out.println(res[0]);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
参考下如下代码:
JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory.newInstance();
//你的wsdl地址
Client client = clientFactory.createClient("http://localhost:8080/helloWorld?wsdl");
Object[] res = client.invoke("sayHello", "chhgge");
System.out.println(res[0]);
如果解决你问题 请采纳
谢谢
JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory.newInstance();
//你的wsdl地址
Client client = clientFactory.createClient("http://localhost:8080/helloWorld?wsdl");
Object[] res = client.invoke("sayHello", "chhgge");
System.out.println(res[0]);
如果解决你问题 请采纳
谢谢
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
检查一下是否是包名的问题。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询