Hi,
I created a simple webservice. Now I would like to call it from an aspx page.
I tried the following code, but I keep getting a remote server error.
When I try to access the webservice directly
(http://localhost/webserviceTest/Service1.asmx/Hello), I also get an error:
Request format is unrecognized.
What am I missing here ?
string url = "http://localhost/webserviceTest/Service1.asmx/Hello";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "GET";
req.ContentType = "application/x-www-form-urlencoded";
// req.Timeout = 100000000;
HttpWebResponse result = (HttpWebResponse)req.GetResponse();
Stream ReceiveStream = result.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
StreamReader sr = new StreamReader( ReceiveStream, encode );
Response.Write("<br>Flux de reponse");
Char[] read = new Char[256];
int count = sr.Read( read, 0, 256 );
Response.Write("HTML...<br>");
while (count > 0)
{
String str = new String(read, 0, count);
Response.Write(str);
count = sr.Read(read, 0, 256);
}
Response.Write("<br>");
Thanks for your help;
Oliver
Softwaremaker - 09 Aug 2004 10:23 GMT
IMHO, it seems to me your URI is not in proper format
The extension .asmx should be in endpoint of your call before the receiving
ASP.NET Runtime knows how to parse it properly.
Did u try http://localhost/webserviceTest/Hello/Service1.asmx ?

Signature
Thank you very much
Warmest Regards,
Softwaremaker
Architect | Evangelist | Consultant
+++++++++++++++++++++++++++++++++
> Hi,
>
[quoted text clipped - 31 lines]
> Thanks for your help;
> Oliver
Oliver - 09 Aug 2004 10:51 GMT
Hi,
yes I did and I got an 404 not found error...
I must add I can reach the test webservice web interface via the following
url:
http://localhost/webserviceTest/Service1.asmx. And its methods work fine.
This webservice has several methods:
Hello
GetSecurityInfo(string login, string code)
I understood these methods could be reached using the following url
http://localhost/webserviceTest/Service1.asmx/Hell
http://localhost/webserviceTest/Service1.asmx/GetSecurityInfo?login=mylogin&code=mycode
But it seems not to work properly even :(
Does anybody have a clue on this ?
Many thanks for your help
Oliver
> IMHO, it seems to me your URI is not in proper format
>
[quoted text clipped - 39 lines]
> > Thanks for your help;
> > Oliver
Michael Riggio - 16 Aug 2004 19:16 GMT
You need to enable HTTP GET operations in your web.config file. Here's what
mine looks like:
<webServices>
<protocols>
<remove name="HttpSoap1.2"/>
<add name="HttpSoap"/>
<remove name="HttpPostLocalhost"/>
<add name="HttpPost" />
<add name="HttpGet" />
</protocols>
</webServices>
> Hi,
>
[quoted text clipped - 10 lines]
> I understood these methods could be reached using the following url
> http://localhost/webserviceTest/Service1.asmx/Hello
http://localhost/webserviceTest/Service1.asmx/GetSecurityInfo?login=mylogin&code=mycode
> But it seems not to work properly even :(
>
[quoted text clipped - 46 lines]
> > > Thanks for your help;
> > > Oliver