473,958 Members | 2,108 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Execute stored procedure via web method.

From a vb.net application I'm want to execute an Oracle Stored Procedure via
a web service. What would be the best way to approach this? I can't pass and
Oracle Command or the parameter objects object to the Webservice, cause
they're not serializable. How would I get the parameters to the web method?
Is there a dynamic P/SQL statement string that I can pass to the web method
and execute it as such? I've been searching for a method and or idea of how
to do this, I would appreciate some professional advice.
Best Regards,

Russ.
Nov 21 '05 #1
3 8188
Russell Verdun wrote:
From a vb.net application I'm want to execute an Oracle Stored
Procedure via a web service. What would be the best way to approach
this? I can't pass and Oracle Command or the parameter objects object
to the Webservice, cause they're not serializable. How would I get the
parameters to the web method? Is there a dynamic P/SQL statement
string that I can pass to the web method and execute it as such? I've
been searching for a method and or idea of how to do this, I would
appreciate some professional advice.


Did you read the answer I gave to this question the first time you posted it? There's no magic bullet solution for this. You can't use the built in types because they're not XML serializable, so you need to write your own. You then need to map back and forth from your types at the web service interop level to the real command object types internally. Best case scneario, if you don't need all the features of a command (e.g. parameters), you can just take and return a string, but I even suggested a nice little schema you can implement to accept parameters in my reply to your initial request for help with this.

HTH,
Drew
Nov 21 '05 #2
Yes, I did get your answer, but not sure where to start, I'm not versed in
XML, but it looks straight forward, where would XML code go?

Russ
"Drew Marsh" <dr****@hotmail .no.spamming.co m> wrote in message
news:uW******** ******@TK2MSFTN GP12.phx.gbl...
Russell Verdun wrote:
From a vb.net application I'm want to execute an Oracle Stored
Procedure via a web service. What would be the best way to approach
this? I can't pass and Oracle Command or the parameter objects object
to the Webservice, cause they're not serializable. How would I get the
parameters to the web method? Is there a dynamic P/SQL statement
string that I can pass to the web method and execute it as such? I've
been searching for a method and or idea of how to do this, I would
appreciate some professional advice.
Did you read the answer I gave to this question the first time you posted

it? There's no magic bullet solution for this. You can't use the built in
types because they're not XML serializable, so you need to write your own.
You then need to map back and forth from your types at the web service
interop level to the real command object types internally. Best case
scneario, if you don't need all the features of a command (e.g. parameters),
you can just take and return a string, but I even suggested a nice little
schema you can implement to accept parameters in my reply to your initial
request for help with this.
HTH,
Drew

Nov 21 '05 #3
Russell Verdun wrote:
Yes, I did get your answer, but not sure where to start, I'm not
versed in XML, but it looks straight forward, where would XML code go?


Ahh, well we can help you out there. Unfortunately the answer to your question is a lot longer than could possibly be explained and understood in a newsgroup posting. I highly suggest reading up on XML, XML Schema and WSDL. However, I'll explain how I would do it from a pure .NET perspective and hopefully you can run with it from there.

I would suggest something like the following...

An schema like:

<xs:schema id="SimpleComma ndExample" targetNamespace ="uri:marsh-samples-SimpleCommand" elementFormDefa ult="qualified"
xmlns="uri:mars h-samples-SimpleCommand" xmlns:xs="http://www.w3.org/2001/XMLSchema"
attributeFormDe fault="unqualif ied">
<xs:complexTy pe name="SimpleCom mand">
<xs:sequence>
<xs:element name="parameter s" minOccurs="0" maxOccurs="1">
<xs:complexType >
<xs:sequence>
<xs:sequence>
<xs:element name="parameter " type="SimpleCom mandParameter" minOccurs="0" maxOccurs="unbo unded" />
</xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="text" type="xs:string " />
</xs:complexType>
<xs:complexTy pe name="SimpleCom mandParameter">
<xs:attribute name="name" type="xs:string " />
<xs:attribute name="value" type="xs:string " />
<xs:attribute name="type" type="xs:QName" />
</xs:complexType>
<xs:element name="command" type="SimpleCom mand"></xs:element>
</xs:schema>

Which would result in instance documents like:

<command xmlns="uri:mars h-samples-SimpleCommand" xmlns:xsd="http ://www.w3.org/2001/XMLSchema" text="SELECT * FROM MyTable WHERE myField = @myParameter">
<parameters>
<parameter name="@myParame ter" type="xsd:int" value="1" />
</parameters>
</command>

And a web method that handles such commands like:

<codeSnippet language="C#">
[WebMethod]
[SoapDocumentMet hod(ParameterSt yle=SoapParamet erStyle.Bare, Use=SoapBinding Use.Literal)]
[return:XmlEleme nt("results", Namespace="uri: marsh-samples-MyServiceTypes" )]
public XmlDataDocument ExecuteCommand([XmlElement("com mand", Namespace="uri: marsh-samples-SimpleCommand")] XmlElement commandElement)
{
// TODO: run a validating reader over the element if you're concerned someone might pass you invalid instances

SqlCommand command = new SqlCommand(comm andElement.GetA ttribute("text" ));

// NOTE: assumes schema is in default namespace which it probably wouldn't be, so make sure to use overload where
// XmlNamespaceMan ager is passed and use namespace prefix on XPath elements
XmlNodeList parameterElemen ts = commandElement. SelectNodes("pa rameters/parameter");

if(parameterEle ments.Count > 0)
{
SqlParameterCol lection commandParamete rs = command.Paramet ers;

foreach(XmlElem ent parameterElemen t in parameterElemen ts)
{
string xsdNamespacePre fix = commandElement. OwnerDocument.G etPrefixOfNames pace("http://www.w3.org/2001/XMLSchema");

SqlParameter parameter = new SqlParameter();
parameter.Param eterName = parameterElemen t.GetAttribute( "name");

string parameterElemen tValue = parameterElemen t.GetAttribute( "value");

string parameterXsdTyp e = parameterElemen t.GetAttribute( "type");
string[] qNameParts = parameterXsdTyp e.Split(':');

if(qNameParts[0] != xsdNamespacePre fix)
{
throw new NotSupportedExc eption("Expecti ng parameter types only from the Xml Schema Definition namespace.");
}

object parameterValue;

switch(qNamePar ts[1])
{
case "int":
case "nonNegativeInt eger":
parameterValue = XmlConvert.ToIn t32(parameterEl ementValue);

break;

case "string":
parameterValue = parameterElemen tValue;

break;

// TODO: handle all the XSD types you want support

default:
throw new NotSupportedExc eption(string.F ormat("Unsuppor ted XSD type specified: {0}.", parameterXsdTyp e));
}

parameter.Value = parameterValue;
}
}

// TODO: execute the command and get back a real, filled dataset
DataSet resultDataSet = new DataSet();

XmlDataDocument result = new XmlDataDocument (resultDataSet) ;

return result;
}
</codeSnippet>

HTH,
Drew
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5071
by: Thomas Scheiderich | last post by:
Why would you use the Recordset object over the Execute method of getting data from your Sql database. For example, I have the following: Execute Method *************************************************************** Set connectionToDatabase=Server.CreateObject("ADODB.Connection") connectionToDatabase.ConnectionTimeout = 60 connectionToDatabase.Open "DSN=Customer;user id=SA;password="
2
13633
by: Matt | last post by:
I want to exexute stored procedure in ASP, but it has error "Microsoft VBScript compilation (0x800A0401) Expected end of statement" on line (1). The stored procedure "sp_emp" contain "select * from Employee;" <% Dim objRS, sqlStmt set objRS = Server.CreateObject("ADODB.Recordset") Dim conn Set conn = Server.CreateObject("ADODB.Connection")
0
6718
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft Visual Basic .NET version of this article, see 308049. For a Microsoft Visual C++ .NET version of this article, see 310071. For a Microsoft Visual J# .NET version of this article, see 320627. This article refers to the following Microsoft .NET...
2
2056
by: Noloader | last post by:
Hello, Access XP, SQL Server 2000 Is it possible to hide a SP under Queries in Access, yet still be able to Execute it from Access? (Similar to hiding Tables, then using Views) We hooked up a custom form to accept the input parameters (MS Feature Request!) for the Stored Procedure. We had two problems with MS's
2
3346
by: Eli | last post by:
Hi all We currently have a strange problem with calling a Stored Procedure (SQL Database) in our C# Project. The only error I get is "System error" which says a lot :) Background: We have several stored procedures to Insert and update datas in our SQL database. Some stored procedures are smaller (insert datas in only one table) and some of them are quite big (insert datas in several
8
9575
by: Jiggaz | last post by:
Hi, In my ASPX Page, i have a form for signup. And whene user click on the button, the event Button1_Click must use a stored procedure. But instead of use stored proc, i get this exception : _____ System.Data.SqlClient.SqlException: EXECUTE permission denied on object 'CreateAccount', database 'wizou', schema 'dbo'. at
7
3230
by: JIM.H. | last post by:
Hello, Is there any difference to between SLQ string in the code and call execute query and call a stored procedure and execute the query that way concerning speed, effectiveness, reliability, …? Thanks, Jim.
0
2343
by: franjorge | last post by:
Hi, I have created two stored procedures via VB using this code: sql = "CREATE PROC " & nombre_proc & " AS SELECT *" & _ " From MBM_PUNTOS_SCE_SIN_COINCIDIR_SIEGE_FALTA_PM_NE_" & mes & _ " WHERE (((IDU) Like 'czz*' Or (IDU) Like 'cam*' Or (IDU) _ Like 'szz*' Or (IDU) Like 'J*' Or (IDU) Like 'G*' Or (IDU) _ Like 'U*'))" & " ORDER BY IDU;"
1
5970
by: shsandeep | last post by:
I 'recreated' a stored procedure. Earlier, i had given privileges to a particular group but now (after rebuilding) when I try to grant execute privilege for the SP to the same user group, it gives me the below message. Any clues on this?? SQL0458N In a reference to routine "SITSCHM.SP_ERND_PREM" by signature, a matching routine could not be found. SQLSTATE=42883
0
10066
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11697
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9986
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7521
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6296
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6439
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
5049
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4630
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3650
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.