When I check the url in my browser my web service work correctly but when I call my link from my store procedure throw exception like this
System.InvalidOperationException: Request format is invalid: .
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
my web service is:
[WebMethod]
public string Upload(string WarrantyCode, string Serial, string ProductTitle, string ShopCenter, string AddDate, string Bill)
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = new SqlConnection(Roozbeh.CnnStr);
cmd.CommandText = "INSERT INTO Guarranty VALUES (@WarrantyCode, @Serial, @ProductTitle, @ShopCenter, @AddDate, 1, @Bill)";
cmd.Parameters.AddWithValue("@WarrantyCode", WarrantyCode);
cmd.Parameters.AddWithValue("@Serial", Serial);
cmd.Parameters.AddWithValue("@ProductTitle", ProductTitle);
cmd.Parameters.AddWithValue("@ShopCenter", ShopCenter);
cmd.Parameters.AddWithValue("@AddDate", AddDate);
cmd.Parameters.AddWithValue("@Bill", Bill);
try
{
cmd.Connection.Open();
cmd.ExecuteNonQuery();
return "Roozbeh";
}
catch (Exception ex)
{
return ex.Message;
}
finally
{
cmd.Connection.Close();
}
}
and my store procedure is:
CREATE PROC Upload
AS
DECLARE @WarrantyCode AS NVARCHAR(20)
DECLARE @Serial AS NVARCHAR(50)
DECLARE @ProductTitle AS NVARCHAR(50)
DECLARE @ShopCenter AS NVARCHAR(70)
DECLARE @AddDate AS NVARCHAR(50)
DECLARE @Bill AS NVARCHAR(50)
SET @WarrantyCode = '123456'
SET @Serial = '123456'
SET @ProductTitle= '123456'
SET @ShopCenter= '123456'
SET @AddDate = '2014-01-01'
SET @Bill = '123456'
Declare @Obj as Int;
Declare @Uri as Varchar(8000);
Declare @Response as Varchar(8000);
DECLARE @hr AS INT
SET @Uri = 'http://MY IP GOES HERE:9671/MyWebService.asmx/Upload?WarrantyCode=' + @WarrantyCode + '&Serial=' + @Serial + '&ProductTitle=' + @ProductTitle + '&ShopCenter=' + @ShopCenter + '&AddDate=' + @AddDate + '&Bill=' + @Bill
EXEC sp_OACreate 'MSXML2.ServerXMLHttp.3.0', @obj OUT
EXEC sp_OAMethod @obj, 'open', NULL, 'POST', @Uri, false
EXEC sp_OAMethod @obj, 'send'
EXEC sp_OAGetProperty @obj, 'ResponseText', @Response OUTPUT
SELECT @Response AS [response], CHARINDEX('amiressami.com', @Response) AS IsOK, CHARINDEX('Hello', @Response) AS Result
EXEC sp_OADestroy @obj
RETURN
created link by my SP is:
http://MY IP:9671/MyWebService.asmx/Upload?WarrantyCode=123456&Serial=123456&ProductTitle=123456&ShopCenter=123456&AddDate=2014-01-01&Bill=123456
it work on browser correctly but in SP not work