Showing posts with label http. Show all posts
Showing posts with label http. Show all posts

Wednesday, March 21, 2012

Post to HTTP With paramerters Options

Hi,

Please could some of the experts out there advise on the best way to acheive the following please. . .

In a SQL table, I have a field that when it drops to below 5, i want to automatically run a Stored Procedure that then connects to a URL to run a ASP.NET script.

IE:
In table users, there is a field called Money.
When Money reaches < 5
Run Stored Procedure
The Stored Procedure then 'somehow' sends a trigger to a URL with
paramerters as per below
www.mydomainname.com?money=4&name=peter

Any help/guidence appriciated as i am really lost on where to start!

Thanks
H

Create a triggered event on your table that does something when the 'money' column changes.

CREATE TRIGGER trgMoneyUpd

ON users

FOR UPDATE

AS

IF UPDATE(Money)

... call your ESP ...

END

Create an extended stored procedure to construct the string you want and open the URL.

http://msdn2.microsoft.com/en-US/library/aa197263(SQL.80).aspx

Hope that helps,

John (MSFT)

Remember to mark your question as answered if it is answered.

|||

Thanks for that John;

Now i have the trigger part working fine, but for the life of me i cannot seem to get my head around the extended stored procedure;

Does anyone have a simple sample they could provide that enables me to do what i want?

Thanks

Harry

|||Hi,

nothing for your solution about the extended stored procedure, but concerning the trigger, you should see that it is able to handle multiple affected rows and no affected rows (a trigger is fired regardless if a row is affected or not) , as the above mentioned one does not do that.

Jens K. Suessmeyer

http://www.sqlserver2005.de
|||

Harry,

The trigger can call into a CLR stored procedure. Inside the CLR stored procedure you would write some .Net Framework code which will call out to the URL. Something like the following:

Code Snippet

using System;
using System.Net;

namespace InSrvWebClient
{
public class MyHttpClient
{
public static String CallWebURL()
{
String retValue = "";
String resText = "";
System.IO.Stream httpReqBodyStream;
System.IO.Stream httpResBodyStream;
System.IO.StreamWriter httpReqBody;
System.IO.StreamReader httpResBody;
System.Text.StringBuilder httpReqString;

httpReqString = new System.Text.StringBuilder(10);

try {
// Create HTTP connection
System.Net.HttpWebRequest httpClient = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(@."http://www.mydomainname.com?money=4&name=peter");

// Set network credentials if needed

/*
String strUserName = @."myUser";

String strUserPwd = @."pwd";
System.Net.NetworkCredential myCred = new System.Net.NetworkCredential(strUserName, strUserPwd);

System.Net.CredentialCache netCreds = new System.Net.CredentialCache();
netCreds.Add(new Uri(@."www.mydomainname.com?money=4&name=peter");

// Set network credentials if needed

/*
String strUserName = @."myUser";

String strUserPwd = @."pwd";
System.Net.NetworkCredential myCred = new System.Net.NetworkCredential(strUserName, strUserPwd);

System.Net.CredentialCache netCreds = new System.Net.CredentialCache();
netCreds.Add(new Uri(@."http://www.mydomainname.com"), "NTLM", myCred);
netCreds.Add(new Uri(@."http://www.mydomainname.com"), "Digest", myCred);
netCreds.Add(new Uri(@."http://www.mydomainname.com"), "Kerberos", myCred);

*/

// Set Request settings
//httpClient.Credentials = netCreds;
//httpClient.ContentType = "text/xml; charset=utf-8";
httpClient.KeepAlive = true;
httpClient.Method = "GET"; // "POST"
//httpClient.PreAuthenticate = true;
httpClient.ProtocolVersion = System.Net.HttpVersion.Version11;
httpClient.Timeout = 120000;

try {
// Get and write request body stream
//httpReqBodyStream = httppClient.GetRequestStream();
//httpReqBody = new System.IO.StreamWriter(httpReqBodyStream, System.Text.Encoding.UTF8);
//httpReqBody.Flush();
//httpReqBody.Write(soapReqString.ToString());
//httpReqBody.Close();

// Get and parse response body stream
System.Net.HttpWebResponse httpRes = (System.Net.HttpWebResponse) httpClient.GetResponse();
if (httpRes.StatusCode == System.Net.HttpStatusCode.OK)
{
httpResBodyStream = httpRes.GetResponseStream();
httpResBody = new System.IO.StreamReader(httpResBodyStream, System.Text.Encoding.UTF8);
resText = httpResBody.ReadToEnd();

// parse any responses as necessary
}
else
retValue = httpRes.StatusCode.ToString() + ": " + httpRes.StatusDescription;
httpRes.Close();
}
catch (ProtocolViolationException protE)
{
retValue = protE.ToString();
}
}
catch (WebException webE)
{
retValue = webE.ToString();
}
return retValue;
}
}
}

You will then need to register the assembly (dll) with SQL Server:

Code Snippet

create assembly testDll from '' WITH permission_set = external_access
go

CREATE FUNCTION InProcWebRequest()
RETURNS nvarchar(4000)
AS EXTERNAL NAME testDll.[InSrvWebClient.MyHttpClient].CallWebURL
go

For more information on creating a CLR stored procedure please see: http://msdn2.microsoft.com/en-us/library/5czye81z(VS.80).aspx

HTH,

Jimmy

Monday, March 12, 2012

Possible to set http://localhost/Reports default start report?

SQL 2005
Is it possible to set a default start report? I have a report which contains hyperlinks to all the other reports, I'd like to just load this one by default when a user hits: http://machine/Reports

Perhaps I'm barking up the wrong tree and need to set this in IIS? I want users to still be able to make their way back to the /Reports folder lists also.

- Thanks in advanceI would rather set a new virtual directory with pointing / redirecting to the new folder than messing with the old settings. But with that there would be not point in returning to the main folder structure, unless you put it as a hyperlink inyour report.

HTH, jens Suessmeyer.

http://www.sqlserver2005.de

Friday, March 9, 2012

Possible to make "Detail View" default in Report Mgr?

Is there a config file where this can be modified such that the views in http://SomeWebServer/Reports will be Details view by default?Still wondering about this. I reviewed the CSS one day for the site, but didn't see this in there.

Possible to make "Detail View" default in Report Mgr?

Is there a config file where this can be modified such that the views in http://SomeWebServer/Reports will be Details view by default?Still wondering about this. I reviewed the CSS one day for the site, but didn't see this in there.

Wednesday, March 7, 2012

Possible SOAP version mismatch

Hi,
I am getting an error when I go to view my websites Report Manager. i go to
http://www.mysite.com/Reports (reports maps to the Report Manager folder).
when ever i go there i keep getting some generic Error Page. the only
information it has on there is: Possible SOAP version mismatch: Envelope
namespace http://schemas.xmlsoap.org/wsdl/ was unexpected. Expecting
http://schemas.xmlsoap.org/soap/envelope/.
I dont know how this has happened. Can anyone help me?
Thank you,
PaulHave you come up with a solution yet?
I have the same error. I had installed the Enterprise version of RS with
the database and report manager on one server - and applied SP1. I then
installed the Enterprise RS Report Manger on another machine and am using the
first server's SQL Server to house another instance of the Report Server DB.
Once installed, I get the 'SOAP version mismatch' error when trying to view
the Report Manager.
I tried upgrading to SP1, but still get the error. Anyone see this issue
before?
"Paul W" wrote:
> Hi,
> I am getting an error when I go to view my websites Report Manager. i go to
> http://www.mysite.com/Reports (reports maps to the Report Manager folder).
> when ever i go there i keep getting some generic Error Page. the only
> information it has on there is: Possible SOAP version mismatch: Envelope
> namespace http://schemas.xmlsoap.org/wsdl/ was unexpected. Expecting
> http://schemas.xmlsoap.org/soap/envelope/.
> I dont know how this has happened. Can anyone help me?
> Thank you,
> Paul
>
>|||I also have the same error. Were you able to find out what the answer is?
If you haven't I'll break down and pay Microsoft for the answer and then post
it here. Can you please reply.
"Paul W" wrote:
> Hi,
> I am getting an error when I go to view my websites Report Manager. i go to
> http://www.mysite.com/Reports (reports maps to the Report Manager folder).
> when ever i go there i keep getting some generic Error Page. the only
> information it has on there is: Possible SOAP version mismatch: Envelope
> namespace http://schemas.xmlsoap.org/wsdl/ was unexpected. Expecting
> http://schemas.xmlsoap.org/soap/envelope/.
> I dont know how this has happened. Can anyone help me?
> Thank you,
> Paul
>
>|||I had some other staff work this issue out on the server side and will need
to double check with them for the exact solution. But, if I remember
correctly, it had something to do with the server name being uppercase - but
RS was trying to access it using all lowercase letters (or vice versa).
I'll see if I can get the exact story posted.
-mike
"Shane McEwan" wrote:
> I also have the same error. Were you able to find out what the answer is?
> If you haven't I'll break down and pay Microsoft for the answer and then post
> it here. Can you please reply.
> "Paul W" wrote:
> > Hi,
> > I am getting an error when I go to view my websites Report Manager. i go to
> > http://www.mysite.com/Reports (reports maps to the Report Manager folder).
> > when ever i go there i keep getting some generic Error Page. the only
> > information it has on there is: Possible SOAP version mismatch: Envelope
> > namespace http://schemas.xmlsoap.org/wsdl/ was unexpected. Expecting
> > http://schemas.xmlsoap.org/soap/envelope/.
> >
> > I dont know how this has happened. Can anyone help me?
> > Thank you,
> > Paul
> >
> >
> >