WebService新手求救

Forever_He 2009-06-14 11:01:19
今天学做一个HelloWorld的WebService用的是cxf 2.0.4的包...
服务器写完后启动成功...客户端调用就出错了,google了好长时间看了好多资料都没有找到原因..各位大哥帮个忙看哈...
客户端报错信息:
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Fault occurred while processing.
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:175)
at $Proxy15.sayHello(Unknown Source)
at main.HelloWorldClient.main(HelloWorldClient.java:13)
Caused by: org.apache.cxf.binding.soap.SoapFault: Fault occurred while processing.
客户端代码:

public static void main(String[] args) {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(HelloWorld.class);
factory.setAddress("http://localhost:8080/WebService");
HelloWorld helloWorld = (HelloWorld) factory.create();
System.out.println("==========");
System.out.println(helloWorld.sayHello("webservice"));
}


服务器代码:
package test;
import javax.jws.WebService;

@WebService
public interface HelloWorld {
public String sayHello(String content);
}

package test;

import javax.jws.WebService;

@WebService
public class HelloWorldImpl implements HelloWorld {
public String sayHello(String content) {
System.out.println("qw---------sayhello");
return "server:"+content;
}
}
  public static void main(String args[]) throws Exception {
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
factory.setServiceClass(HelloWorldImpl.class);
factory.setAddress("http://localhost:8080/WebService");
Server server = factory.create();
server.start();
}
...全文
980 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
wxx19890503 2012-03-06
  • 打赏
  • 举报
回复
真心的讨厌这种只要自己解决问题就不分享的人
ldwtxwh 2010-11-08
  • 打赏
  • 举报
回复
楼主,我也遇到你说的问题了,能不能公布下解决方案啊。
zhangxixrh 2010-09-26
  • 打赏
  • 举报
回复
好鄙视楼主,竟然不结贴,解决了也不说哈
aguai0 2010-04-16
  • 打赏
  • 举报
回复
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Fault occurred while processing. 这个问题怎么解决的啊,麻烦说下啊。谢谢
yizhizouxiaqu 2009-07-18
  • 打赏
  • 举报
回复
楼主那个怎么解决的啊,告诉告诉我,谢谢
laorer 2009-06-16
  • 打赏
  • 举报
回复
http://topic.csdn.net/t/20051208/15/4446459.html

http://www.cnblogs.com/luowei/archive/2008/01/15/1040224.html

Forever_He 2009-06-15
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 laorer 的回复:]
对 ws 没研究过,你看可不可以把传来的内容保存成 xml ,看看获得的 xml 是不是符合要求
[/Quote]
我的服务器端根本就没有调用方法...

laorer 2009-06-15
  • 打赏
  • 举报
回复
对 ws 没研究过,你看可不可以把传来的内容保存成 xml ,看看获得的 xml 是不是符合要求
Forever_He 2009-06-15
  • 打赏
  • 举报
回复
各位大哥...帮个忙呀,上面的问题我已经解决了...现在又出了新问题
我现在想用cxf的框架写个客户端来调用天气预报的WebService...
可是现在报
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: 服务器未能识别 HTTP 头 SOAPAction 的值:
我的客户端代码:
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;

public class WeatherClient {
public static void main(String[] args) {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(Weather.class);
factory.setAddress("http://www.webxml.com.cn/WebServices/WeatherWebService.asmx");
Weather weather = (Weather) factory.create();
System.out.println("==========");
String[] arrayCity = weather.getSupportCity("all");
for (int i = 0; i < arrayCity.length; i++) {
System.out.println(arrayCity[i]);
}
}
}
Forever_He 2009-06-14
  • 打赏
  • 举报
回复
我上面的那个main主函数是单独在一个启动service的类中的...不是在接口的实现类中的..
Forever_He 2009-06-14
  • 打赏
  • 举报
回复
我上面的那个main主函数是单独在一个启动service的类中的...不是在接口的实现类中的..

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧