Java调用asp.net webservice传值为null问题

andyking_ 2009-07-10 10:16:39
最近用asp.net写了一个webservice供Java调用,但是接收到Java方传过来的值总是null,而返回给Java方的值是可以收到的,在网上查了很多资料,有的说是namespaces的事,要在每个参数上都加上namespaces,但是怎么个加法,谁知道告诉我一下,给个例子看看,或者有更好的解决办法拿出来分享一下,谢谢!分数不够可以再加
...全文
370 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
slimboy123 2009-07-22
  • 打赏
  • 举报
回复
你可以根据wsdl文件,用wsdl.exe生成webservice代理类

http://blog.csdn.net/slimboy123/archive/2009/07/13/4344914.aspx
slimboy123 2009-07-22
  • 打赏
  • 举报
回复
可能是你命名空间问题

示例:


namespace TestDemo
{
using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Collections.Generic;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Diagnostics;
using System.Xml.Serialization;


/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.test.com")]
public partial class MyClass
{

private string messageField;
private string otherdataField;

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(IsNullable = true)]
public string message
{
get
{
return this.messageField;
}
set
{
this.messageField = value;
}
}


/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(IsNullable = true)]
public string otherdata
{
get
{
return this.otherdataField;
}
set
{
this.otherdataField = value;
}
}
}


/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
[System.Web.Services.WebServiceAttribute(Namespace = "http://www.test.webservice.com")]
[System.Web.Services.WebServiceBindingAttribute(Name = "TestHttpBinding", Namespace = "http://www.test.com")]
[System.Web.Services.Protocols.SoapDocumentService(RoutingStyle = SoapServiceRoutingStyle.RequestElement)]
public partial class TestService : System.Web.Services.WebService
{
/// <remarks/>
[System.Web.Services.WebMethodAttribute()]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace = "http://www.test.com", ResponseNamespace = "http://www.test.com", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: System.Xml.Serialization.XmlElementAttribute("out", IsNullable = true)]
public int testservice([System.Xml.Serialization.XmlElementAttribute(IsNullable = true)] MyClass in0)
{
if(in0 == null)
{
return 0;
}
else
{
return 1;
}
}
}
}

qu_zhitao 2009-07-11
  • 打赏
  • 举报
回复

12,162

社区成员

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

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