简体   繁体   English

存储过程到Web服务

[英]Stored Procedure to Web Service

I would like to know if there is an automatic (or effortless) way to map SQL Server stored procedures to web services? 我想知道是否有一种自动(或轻松)方式将SQL Server存储过程映射到Web服务?

The problem is, I need to allow a third party application to interact/integrate data with an ERP system. 问题是,我需要允许第三方应用程序与ERP系统交互/集成数据。 This ERP provides several stored procedures to do that. 该ERP提供了一些存储过程来实现这一目的。 Those stored procedures also contain validation and tons of business logic. 这些存储过程还包含验证和大量业务逻辑。

But, this external app prefers to go through web services. 但是,此外部应用程序更喜欢通过Web服务。

So, the first approach is to create a web service and map each stored procedure to a method (or may be split in different endpoints) but, I don't know is there is some tool, if it can be done using Entity Framework, etc. 因此,第一种方法是创建一个Web服务,并将每个存储过程映射到一个方法(或者可以拆分为不同的端点),但是,我不知道有没有某种工具,如果可以使用Entity Framework完成,等等

You could write something yourself using SMO (Sql management objects), if we are talking about 2 stored procs it may not be worth it but if its 100... 您可以使用SMO(Sql管理对象)自己编写一些东西,如果我们谈论的是2个存储过程,那么可能不值得,但是如果它是100个...

this is a demonstration to use SMO. 这是使用SMO的演示。 the same idea could be used for writing out your service contract etc. 同样的想法可以用来签出您的服务合同等。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;


    class Program
    {
        static void Main(string[] args)
        {

            Server srv = new Server("serverName");
            Database db = srv.Databases["myDBName"];

            foreach (StoredProcedure proc in db.StoredProcedures)
            {

                StringBuilder methodWriter = new StringBuilder();

                methodWriter.Append("public void " + proc.Name + "(");

                foreach(Parameter param in proc.Parameters)
                {
                    string csharpData = string.Empty;

                    if (param.DataType == DataType.DateTime) { csharpData = "DateTime " + param.Name; }
                    //...

                    methodWriter.Append(csharpData + ", ");

                }

                methodWriter.Append("){}");

            }

        }
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过ASMX Web服务将XML参数传递给存储过程 - Passing XML parameter to a stored procedure via ASMX web service 存储过程不是从Web服务执行的,而是在SSMS中执行的 - Stored procedure doesn't execute from a web service, but does in SSMS WFC Web服务执行具有权限的SQL Server存储过程 - WFC web service executing a SQL Server stored-procedure with permissions 通过数据服务存储过程 - Stored procedure through Data Service 为什么我的Web服务/存储过程将插入值截断为一个字符? - why is my web service/stored procedure truncating my insert values to one char? 从ac#Web服务调用PL / SQL存储过程的ORA 00936错误 - ORA 00936 error calling a PL/SQL stored procedure from a c# web service 手持式调用Web Service或存储过程看起来已被调用两次? - Handheld call Web Service or Stored Procedure look like has been called twice? 如何在C#中从Web服务的存储过程中获取多个输出参数? - How can I get multiple output parameters from a stored procedure in a web service in C#? 如何创建SQL CLR存储过程以从Web服务获取数据并将结果插入到SQL Server表中 - How to create a SQL CLR stored procedure to get data from a web service and insert results into a SQL Server table ORA-06502:PL / SQL:数字或值错误从C#Web服务调用存储过程 - ORA-06502: PL/SQL: numeric or value error calling a stored procedure from c# web service
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM