【问题标题】:clr stored procedure call wcf service missing parameter valuesclr 存储过程调用 wcf 服务缺少参数值
【发布时间】:2015-01-20 21:08:02
【问题描述】:

我遇到了一个由 CLR 存储过程调用的 WCF 服务的非常奇怪的问题。

基本上,我的服务需要一个元素数组,如下所示:

[ServiceContract]
public class ServiceFoo
{
    [OperationContract]
    bool ImportFoos(IEnumerable<Foo> foos);
}

public class Foo
{
    public int a {get;set;}
    public int b {get;set;}
    public string c {get;set;}
    public int d {get;set;}
    public string e {get;set;}
}

public class wsClient
    {
        public static void ImportFoos(int a, int b, string c, int d, string e)
        {
            ws.ServiceFoo ws = new ws.ServiceFoo();

            bool ImportFooResult = false;
            bool ImportFooResultSpecified = false;

            ws.ImportFoos(new ws.Foo[]
            {
                new ws.Foo
                {
                    a= a,
                    b = b,
                    c = c,
                    d = d,
                    e = e
                }

            }, out ImportFooResult, out ImportFooResultSpecified);
        }
    }

//SQL/CLR

public partial class StoredProcedures
{
    [Microsoft.SqlServer.Server.SqlProcedure]
    public static void sp_import_foo(int a, int b, string c, int d, string e)
    {        
        try
        {
            SqlPipe sqlPipe = SqlContext.Pipe;

            wsClient.ImportFoos(a, b, c, d, e);

            SqlContext.Pipe.Send("OK");
        }
        catch (Exception ex)
        {
            SqlContext.Pipe.Send(ex.Message + " - " + ex.StackTrace);
        }
    }
}


CREATE PROCEDURE [spWcfCall] 
    @a int, 
    @b int, 
    @c nvarchar(max), 
    @d int, 
    @e nvarchar(max)

WITH EXECUTE AS CALLER
AS
    EXTERNAL NAME CLRSample.StoredProcedures.sp_import_foo

在我的服务中设置一个断点,我可以检查只有 C 和 E 参数有值。

有什么线索吗?

【问题讨论】:

    标签: sql-server wcf stored-procedures clrstoredprocedure


    【解决方案1】:
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-13
    • 1970-01-01
    • 1970-01-01
    • 2011-09-22
    • 1970-01-01
    相关资源
    最近更新 更多