调用webservice如何传入对象参数?

applerockhool 2010-07-08 03:00:09
我想调用一个C# 写的webservice,但是方法的参数是一个对象,我应该如何用java传递给他。wsdl如下:

<s:element name="LogEntry_Create">

<s:complexType>

<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="user" type="tns:User"/>
<s:element minOccurs="0" maxOccurs="1" name="Message" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>

<s:complexType name="User">

<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="CompanyName" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="UserName" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string"/>
</s:sequence>
</s:complexType>
...全文
1132 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
applerockhool 2010-07-08
  • 打赏
  • 举报
回复
有没有高手啊?
applerockhool 2010-07-08
  • 打赏
  • 举报
回复
我用的是axis 库调用的
applerockhool 2010-07-08
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 dr_lou 的回复:]

user也无所谓。

完全可以是形如
<user>
<id>1</id>
<name>xuz</name>
</user>
[/Quote]

形式就是如此,可你说的方法如何具体发送请求
dr_lou 2010-07-08
  • 打赏
  • 举报
回复
不知道你用的什么,我用的是httpconnection拼请求,然后解析返回值。
dr_lou 2010-07-08
  • 打赏
  • 举报
回复
user也无所谓。

完全可以是形如
<user>
<id>1</id>
<name>xuz</name>
</user>
dr_lou 2010-07-08
  • 打赏
  • 举报
回复
private static String getSoapRequest(String city) {
StringBuffer sb = new StringBuffer();
sb.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
+ "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
+ "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+ "<soap:Body> <getWeatherbyCityName xmlns=\"http://WebXml.com.cn/\">"
+ "<theCityName>" + city
+ "</theCityName> </getWeatherbyCityName>"
+ "</soap:Body></soap:Envelope>");
applerockhool 2010-07-08
  • 打赏
  • 举报
回复
ls能说个简单点的方法吗,我是想知道调用时传递参数应该是什么:如下代码:
call.addParameter(new QName("http://www.Conholdate.ControlPanel/",
"LogEntry_Create"),
org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);


基本类型我都可以传,但是User是个对象啊
dr_lou 2010-07-08
  • 打赏
  • 举报
回复
拼soap请求吧。

例如:
private static String getSoapRequest(String city) {
StringBuffer sb = new StringBuffer();
sb.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
+ "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
+ "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+ "<soap:Body> <getWeatherbyCityName xmlns=\"http://WebXml.com.cn/\">"
+ "<theCityName>" + city
+ "</theCityName> </getWeatherbyCityName>"
+ "</soap:Body></soap:Envelope>");
applerockhool 2010-07-08
  • 打赏
  • 举报
回复
难道没有用过?
ronniegxq 2010-07-08
  • 打赏
  • 举报
回复
不懂帮顶
无所依赖 2010-07-08
  • 打赏
  • 举报
回复
帮你顶一下!!接分!
applerockhool 2010-07-08
  • 打赏
  • 举报
回复
最有附上代码,不胜感激

81,091

社区成员

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

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