求购,关于webservice客户需调用问题

ywvision 2011-11-17 03:54:10


String serviceURL = "http://192.168.0.60:8080/sms/services/send?wsdl";

XFireProxyFactory serviceFactory = new XFireProxyFactory();


try {
Client client = new Client(new URL(serviceURL));
Object[] results = client.invoke("send", new String[]{"test","test","13616111666","短信内容"});
System.out.println(results[0]);

} catch (MalformedURLException e) {
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

上述代码是一个webservice的客户端程序,作发短信的测试用的,不知道哪儿有问题。错误提示是

org.codehaus.xfire.XFireRuntimeException: Could not find operation with name http://192.168.0.60:8080/sms/services/send
at org.codehaus.xfire.client.Client.invoke(Client.java:366)
at SmsClient.main(SmsClient.java:43)

请大虾们点拨指正哈
...全文
378 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
ywvision 2011-11-17
  • 打赏
  • 举报
回复
谢谢楼上各位热情的大虾帮助我在线解决。再次感谢
ywvision 2011-11-17
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 ruogannian 的回复:]
Object[] results = client.invoke("send", new String[]{"test","test","13616111666","短信内容"});


改成

Object[] results = client.invoke("Send", new String[]{"test","test","13616111666","短信内容"});
[/Quote]
搞定,晕倒 ,这里面的方法名怎么是大写的哈。被搞死了
若干年 2011-11-17
  • 打赏
  • 举报
回复
Object[] results = client.invoke("send", new String[]{"test","test","13616111666","短信内容"});


改成

Object[] results = client.invoke("Send", new String[]{"test","test","13616111666","短信内容"});
ywvision 2011-11-17
  • 打赏
  • 举报
回复
求救啊!!!
ywvision 2011-11-17
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 huan89517 的回复:]
WS一直用封装方法调用来着

没仔细看过怎么封装的

但我记得 Client client = new Client(new URL(serviceURL));
这里面的URL是没有?wsdl的

就是直接写String serviceURL = "http://192.168.0.60:8080/sms/services后面加你的类名

你可以先删掉后面的试一下
[/Quote]

改成 String serviceURL = "http://10.100.1.77:8080/sms/services/send"; 后,报
javax.wsdl.WSDLException: WSDLException (at /html): faultCode=INVALID_WSDL: Expected element '{http://schemas.xmlsoap.org/wsdl/}definitions'.
at com.ibm.wsdl.xml.WSDLReaderImpl.checkElementName(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.parseDefinitions(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
at org.codehaus.xfire.client.Client.<init>(Client.java:235)
at org.codehaus.xfire.client.Client.<init>(Client.java:246)
at SmsClient.main(SmsClient.java:19)
越来越迷糊了
huan89517 2011-11-17
  • 打赏
  • 举报
回复
WS一直用封装方法调用来着

没仔细看过怎么封装的

但我记得 Client client = new Client(new URL(serviceURL));
这里面的URL是没有?wsdl的

就是直接写String serviceURL = "http://192.168.0.60:8080/sms/services后面加你的类名

你可以先删掉后面的试一下
ywvision 2011-11-17
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 huan89517 的回复:]
你WS发布类叫什么啊
[/Quote]

帮我看下类名叫什么,我不懂哈。没看过写过webservice服务端和客户端,我得先把客户端调去来。然后想办法整到spring去,在spring里加个定时器和侦听去整进去。不知道我的思路有没有问题
ywvision 2011-11-17
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 ruogannian 的回复:]
Object[] results = client.invoke("send", new String[]{"test","test","13616111666","短信内容"});


你要调用的服务端方法名是send?
[/Quote]

是的。是send,用来发短信的
ywvision 2011-11-17
  • 打赏
  • 举报
回复
<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions targetNamespace="http://service.dfkj.com" xmlns:tns="http://service.dfkj.com" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding" xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:types>
- <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.dfkj.com">
- <xsd:element name="Send">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="in0" nillable="true" type="xsd:string" />
<xsd:element maxOccurs="1" minOccurs="1" name="in1" nillable="true" type="xsd:string" />
<xsd:element maxOccurs="1" minOccurs="1" name="in2" nillable="true" type="xsd:string" />
<xsd:element maxOccurs="1" minOccurs="1" name="in3" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
- <xsd:element name="SendResponse">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
- <wsdl:message name="SendResponse">
<wsdl:part name="parameters" element="tns:SendResponse" />
</wsdl:message>
- <wsdl:message name="SendRequest">
<wsdl:part name="parameters" element="tns:Send" />
</wsdl:message>
- <wsdl:portType name="sendPortType">
- <wsdl:operation name="Send">
<wsdl:input name="SendRequest" message="tns:SendRequest" />
<wsdl:output name="SendResponse" message="tns:SendResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="sendHttpBinding" type="tns:sendPortType">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="Send">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="SendRequest">
<wsdlsoap:body use="literal" />
</wsdl:input>
- <wsdl:output name="SendResponse">
<wsdlsoap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="send">
- <wsdl:port name="sendHttpPort" binding="tns:sendHttpBinding">
<wsdlsoap:address location="http://192.168.0.60:8080/sms/services/send" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

贴上别人给我的地址:http://192.168.0.60:8080/sms/services/send?WSDL
以上是这个地址输入IE后看到的东西
若干年 2011-11-17
  • 打赏
  • 举报
回复
浏览器里打开http://192.168.0.60:8080/sms/services/send?wsdl
ywvision 2011-11-17
  • 打赏
  • 举报
回复
怎么看ws发布的类名。我没写过webservice,不懂。请指教。
若干年 2011-11-17
  • 打赏
  • 举报
回复
Object[] results = client.invoke("send", new String[]{"test","test","13616111666","短信内容"});


你要调用的服务端方法名是send?
huan89517 2011-11-17
  • 打赏
  • 举报
回复
你WS发布类叫什么啊
ywvision 2011-11-17
  • 打赏
  • 举报
回复
地址应该没错哈。能访问的。
huan89517 2011-11-17
  • 打赏
  • 举报
回复
String serviceURL = "http://192.168.0.60:8080/sms/services/"+你ws发布类名;
改成这个试一下

50,523

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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