Wcf调用有参数的方法时参数没有能传值

风一样的大叔 2012-11-05 03:09:24
using System.Data;

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
public interface IWcfService
{
string GetHello();

DataSet GetLocInfo(string locationCode);
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.Xml.Serialization.XmlRootAttribute(ElementName="GetHello", Namespace="http://tempuri.org/")]
public partial class GetHelloRequest
{

public GetHelloRequest()
{
}
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.Xml.Serialization.XmlRootAttribute(ElementName = "GetLocInfo", Namespace = "http://tempuri.org/")]
public partial class GetLocInfoRequest
{

public GetLocInfoRequest(string locationCode)
{
}
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.Xml.Serialization.XmlRootAttribute(ElementName="GetHelloResponse", Namespace="http://tempuri.org/")]
public partial class GetHelloResponse
{

[System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Namespace="http://tempuri.org/", Order=0)]
public string GetHelloResult;

public GetHelloResponse()
{
}

public GetHelloResponse(string GetHelloResult)
{
this.GetHelloResult = GetHelloResult;
}
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.Xml.Serialization.XmlRootAttribute(ElementName = "GetLocInfoResponse", Namespace = "http://tempuri.org/")]
public partial class GetLocInfoResponse
{

[System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Namespace="http://tempuri.org/", Order=0)]
public DataSet GetLocInfoResult;

public GetLocInfoResponse()
{
}

public GetLocInfoResponse(DataSet GetLocInfoResult, string locationCode)
{
this.GetLocInfoResult = GetLocInfoResult;
}
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
public partial class WcfServiceClient : Microsoft.Tools.ServiceModel.CFClientBase<IWcfService>, IWcfService
{

public static System.ServiceModel.EndpointAddress EndpointAddress = new System.ServiceModel.EndpointAddress("http://localhost/WcfService");

public WcfServiceClient() : this(CreateDefaultBinding(), EndpointAddress)
{
}

public WcfServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
base(binding, remoteAddress)
{
addProtectionRequirements(binding);
}

private GetHelloResponse GetHello(GetHelloRequest request)
{
CFInvokeInfo info = new CFInvokeInfo();
info.Action = "http://tempuri.org/IWcfService/GetHello";
info.RequestIsWrapped = true;
info.ReplyAction = "http://tempuri.org/IWcfService/GetHelloResponse";
info.ResponseIsWrapped = true;
GetHelloResponse retVal = base.Invoke<GetHelloRequest, GetHelloResponse>(info, request);
return retVal;
}

public string GetHello()
{
GetHelloRequest request = new GetHelloRequest();
GetHelloResponse response = this.GetHello(request);
return response.GetHelloResult;
}

private GetLocInfoResponse GetLocInfo(GetLocInfoRequest request, string locationCode)
{
CFInvokeInfo info = new CFInvokeInfo();
info.Action = "http://tempuri.org/IWcfService/GetLocInfo";
info.RequestIsWrapped = true;
info.ReplyAction = "http://tempuri.org/IWcfService/GetLocInfoResponse";
info.ResponseIsWrapped = true;
GetLocInfoResponse retVal = base.Invoke<GetLocInfoRequest, GetLocInfoResponse>(info, request);
return retVal;
}

public DataSet GetLocInfo(string locationCode)
{
GetLocInfoRequest request = new GetLocInfoRequest(locationCode);
GetLocInfoResponse response = this.GetLocInfo(request, locationCode);
return response.GetLocInfoResult;
}

public static System.ServiceModel.Channels.Binding CreateDefaultBinding()
{
System.ServiceModel.Channels.CustomBinding binding = new System.ServiceModel.Channels.CustomBinding();
binding.Elements.Add(new System.ServiceModel.Channels.TextMessageEncodingBindingElement(System.ServiceModel.Channels.MessageVersion.Soap11, System.Text.Encoding.UTF8));
binding.Elements.Add(new System.ServiceModel.Channels.HttpTransportBindingElement());
return binding;
}

private void addProtectionRequirements(System.ServiceModel.Channels.Binding binding)
{
if (IsSecureMessageBinding(binding) == false)
{
return;
}
System.ServiceModel.Security.ChannelProtectionRequirements cpr = new System.ServiceModel.Security.ChannelProtectionRequirements();
ApplyProtection("http://tempuri.org/IWcfService/GetHello", cpr.IncomingSignatureParts, true);
ApplyProtection("http://tempuri.org/IWcfService/GetHello", cpr.IncomingEncryptionParts, true);
if ((binding.MessageVersion.Addressing == System.ServiceModel.Channels.AddressingVersion.None))
{
ApplyProtection("*", cpr.OutgoingSignatureParts, true);
ApplyProtection("*", cpr.OutgoingEncryptionParts, true);
}
else
{
ApplyProtection("http://tempuri.org/IWcfService/GetHelloResponse", cpr.OutgoingSignatureParts, true);
ApplyProtection("http://tempuri.org/IWcfService/GetHelloResponse", cpr.OutgoingEncryptionParts, true);
}
this.Parameters.Add(cpr);
ApplyProtection("http://tempuri.org/IWcfService/GetLocInfo", cpr.IncomingSignatureParts, true);
ApplyProtection("http://tempuri.org/IWcfService/GetLocInfo", cpr.IncomingEncryptionParts, true);
if ((binding.MessageVersion.Addressing == System.ServiceModel.Channels.AddressingVersion.None))
{
ApplyProtection("*", cpr.OutgoingSignatureParts, true);
ApplyProtection("*", cpr.OutgoingEncryptionParts, true);
}
else
{
ApplyProtection("http://tempuri.org/IWcfService/GetLocInfoResponse", cpr.OutgoingSignatureParts, true);
ApplyProtection("http://tempuri.org/IWcfService/GetLocInfoResponse", cpr.OutgoingEncryptionParts, true);
}
this.Parameters.Add(cpr);
}
}


wcf服务中有两个方法,GetHello和GetLocInfo
调用GetHello没问题,但是调用GetLocInfo的时候值传不过去,肯定是我配置出了问题,请大家看看我哪边少了东西,谢谢
...全文
237 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
paopao_426 2013-07-10
  • 打赏
  • 举报
回复
赶紧结贴啊 ,我也碰到这情况了
stl2011 2012-11-07
  • 打赏
  • 举报
回复
没遇到过,等待学习
风一样的大叔 2012-11-06
  • 打赏
  • 举报
回复
问题找到了耶,闪粉,晚上节,来着有分啊
using System.Data;

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
public interface IWcfService
{
    string GetHello();

    DataSet GetLocInfo(string locationCode);
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.Xml.Serialization.XmlRootAttribute(ElementName = "GetHello", Namespace = "http://tempuri.org/")]
public partial class GetHelloRequest
{

    public GetHelloRequest()
    {
    }
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.Xml.Serialization.XmlRootAttribute(ElementName = "GetLocInfo", Namespace = "http://tempuri.org/")]
public partial class GetLocInfoRequest
{
    public string locationCode;

    public GetLocInfoRequest()
    {
    }

    public GetLocInfoRequest(string locationCode)
    {
        this.locationCode = locationCode;
    }
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.Xml.Serialization.XmlRootAttribute(ElementName = "GetHelloResponse", Namespace = "http://tempuri.org/")]
public partial class GetHelloResponse
{

    [System.Xml.Serialization.XmlElementAttribute(IsNullable = true, Namespace = "http://tempuri.org/", Order = 0)]
    public string GetHelloResult;

    public GetHelloResponse()
    {
    }

    public GetHelloResponse(string GetHelloResult)
    {
        this.GetHelloResult = GetHelloResult;
    }
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.Xml.Serialization.XmlRootAttribute(ElementName = "GetLocInfoResponse", Namespace = "http://tempuri.org/")]
public partial class GetLocInfoResponse
{

    [System.Xml.Serialization.XmlElementAttribute(IsNullable = true, Namespace = "http://tempuri.org/", Order = 0)]
    public DataSet GetLocInfoResult;

    public GetLocInfoResponse()
    {
    }

    public GetLocInfoResponse(DataSet GetLocInfoResult, string locationCode)
    {
        this.GetLocInfoResult = GetLocInfoResult;
    }
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
public partial class WcfServiceClient : Microsoft.Tools.ServiceModel.CFClientBase<IWcfService>, IWcfService
{

    public static System.ServiceModel.EndpointAddress EndpointAddress = new System.ServiceModel.EndpointAddress("http://localhost/WcfService");

    public WcfServiceClient()
        : this(CreateDefaultBinding(), EndpointAddress)
    {
    }

    public WcfServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
        base(binding, remoteAddress)
    {
        addProtectionRequirements(binding);
    }

    private GetHelloResponse GetHello(GetHelloRequest request)
    {
        CFInvokeInfo info = new CFInvokeInfo();
        info.Action = "http://tempuri.org/IWcfService/GetHello";
        info.RequestIsWrapped = true;
        info.ReplyAction = "http://tempuri.org/IWcfService/GetHelloResponse";
        info.ResponseIsWrapped = true;
        GetHelloResponse retVal = base.Invoke<GetHelloRequest, GetHelloResponse>(info, request);
        return retVal;
    }

    public string GetHello()
    {
        GetHelloRequest request = new GetHelloRequest();
        GetHelloResponse response = this.GetHello(request);
        return response.GetHelloResult;
    }

    private GetLocInfoResponse GetLocInfo(GetLocInfoRequest request, string locationCode)
    {
        CFInvokeInfo info = new CFInvokeInfo();
        info.Action = "http://tempuri.org/IWcfService/GetLocInfo";
        info.RequestIsWrapped = true;
        info.ReplyAction = "http://tempuri.org/IWcfService/GetLocInfoResponse";
        info.ResponseIsWrapped = true;
        GetLocInfoResponse retVal = base.Invoke<GetLocInfoRequest, GetLocInfoResponse>(info, request);
        return retVal;
    }

    public DataSet GetLocInfo(string locationCode)
    {
        GetLocInfoRequest request = new GetLocInfoRequest(locationCode);
        GetLocInfoResponse response = this.GetLocInfo(request, locationCode);
        return response.GetLocInfoResult;
    }

    public static System.ServiceModel.Channels.Binding CreateDefaultBinding()
    {
        System.ServiceModel.Channels.CustomBinding binding = new System.ServiceModel.Channels.CustomBinding();
        binding.Elements.Add(new System.ServiceModel.Channels.TextMessageEncodingBindingElement(System.ServiceModel.Channels.MessageVersion.Soap11, System.Text.Encoding.UTF8));
        binding.Elements.Add(new System.ServiceModel.Channels.HttpTransportBindingElement());
        return binding;
    }

    private void addProtectionRequirements(System.ServiceModel.Channels.Binding binding)
    {
        if (IsSecureMessageBinding(binding) == false)
        {
            return;
        }
        System.ServiceModel.Security.ChannelProtectionRequirements cpr = new System.ServiceModel.Security.ChannelProtectionRequirements();
        ApplyProtection("http://tempuri.org/IWcfService/GetHello", cpr.IncomingSignatureParts, true);
        ApplyProtection("http://tempuri.org/IWcfService/GetHello", cpr.IncomingEncryptionParts, true);
        if ((binding.MessageVersion.Addressing == System.ServiceModel.Channels.AddressingVersion.None))
        {
            ApplyProtection("*", cpr.OutgoingSignatureParts, true);
            ApplyProtection("*", cpr.OutgoingEncryptionParts, true);
        }
        else
        {
            ApplyProtection("http://tempuri.org/IWcfService/GetHelloResponse", cpr.OutgoingSignatureParts, true);
            ApplyProtection("http://tempuri.org/IWcfService/GetHelloResponse", cpr.OutgoingEncryptionParts, true);
        }
        this.Parameters.Add(cpr);
        ApplyProtection("http://tempuri.org/IWcfService/GetLocInfo", cpr.IncomingSignatureParts, true);
        ApplyProtection("http://tempuri.org/IWcfService/GetLocInfo", cpr.IncomingEncryptionParts, true);
        if ((binding.MessageVersion.Addressing == System.ServiceModel.Channels.AddressingVersion.None))
        {
            ApplyProtection("*", cpr.OutgoingSignatureParts, true);
            ApplyProtection("*", cpr.OutgoingEncryptionParts, true);
        }
        else
        {
            ApplyProtection("http://tempuri.org/IWcfService/GetLocInfoResponse", cpr.OutgoingSignatureParts, true);
            ApplyProtection("http://tempuri.org/IWcfService/GetLocInfoResponse", cpr.OutgoingEncryptionParts, true);
        }
        this.Parameters.Add(cpr);
    }
}
风一样的大叔 2012-11-06
  • 打赏
  • 举报
回复
一天都没了啊

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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