java调用c#写的webservice程序时参数传不过去的问题。。急求解答。
如题,求兄弟姐妹们帮帮忙!!
代码如下:
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。。。不知道什么原因引起的,求各位大哥大姐帮帮忙,在线等。