java调用c#写的webservice程序时参数传不过去的问题。。急求解答。

zuizhongmeng 2012-05-14 04:46:50
如题,求兄弟姐妹们帮帮忙!!
代码如下:

c#写的service接口,部署测试正常。

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service () {

//Uncomment the following line if using designed components
//InitializeComponent();
}

[WebMethod]
public string HelloWorld() {
return "Hello World";
}
[WebMethod]
public string HelloWorld1(string parameter)
{

return "Hello World =" + parameter + " = " + DateTime.Now.ToString();
}

}

java调用的方法如下:

public String GetMaterial(String xmlString) {

try {

// 指出service所在URL
String endpoint = "http://localhost:81/webService/Service.asmx";
// 创建一个服务(service)调用(call)
Service service = new Service();
Call call = (Call)service.createCall();// 通过service创建call对象
// 设置service所在URL
call.setTargetEndpointAddress(new java.net.URL(endpoint));
//设置要调用的方法
call.setOperationName( new QName( "http://tempuri.org/","HelloWorld1" ));
//设置该方法需要的参数
call.addParameter( "parameter" , org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
//设置方法返回值的类型
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
call.setUseSOAPAction(true);
//调用该方法
call.setSOAPActionURI("http://tempuri.org/HelloWorld1");
String backStr = (String) call.invoke(new Object[] { xmlString });

System.out.println(backStr);

} catch (Exception e) {
e.printStackTrace();
return e.toString();
}
}


显示的日志为:

WARN : 16:36:40,203 - TcLogger$IC_PrintStream.log:?
Hello World = = 2009-7-6 16:36:40

也就是说xmlString字符串的值没能传到webService。。。不知道什么原因引起的,求各位大哥大姐帮帮忙,在线等。
...全文
2395 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
zuizhongmeng 2012-05-14
  • 打赏
  • 举报
回复
怎么没人回复呢。。。。我确定传的字符串是有值的。可怎么到C#就没值了呢。。哎

81,114

社区成员

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

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