Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / August 2004

Tip: Looking for answers? Try searching our database.

calling a webservice from an aspx page

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Oliver - 09 Aug 2004 09:23 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.