WebService calling from Pocket PC
-
Hi all,
I have created a hello world web service.
I can access using web browser like -
http://localhost/TestWebService2/TestWebService2.asmx
That is good.
I created an Windows application to call that web service.
It worked fine.
I copied that windows application to other computer in the same network.
That windows application worked fine in that computer.
It could call that web service from that computer.
I created a Pocket PC application to call that web service.
I run that PPC application from my Pocket PC which is in the same network as my desktop computer in which Web service is running.
I got an error.
System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it
at System.Net.Sockets.Socket.ConnectNoCheck()
at System.Net.Sockets.Socket.Connect()
at System.Net.Connection.doConnect()
at System.Net.Connection.connect()
at WorkItem.doWork()
at System.Threading.Timer.ring()
Yes. I got that error.
So, from my pocket PC's internet explorer, I typed the address of that WebService as -
http://MyComputerName/TestWebService2/TestWebService2.asmx
It worked fine. I could see the Web Service.
Did I do something wrong in my PPC application?
I included that web service as Add Web Reference.
And just called the function of that web service.
And I don't see any .config file for Pocket PC applications.
I manually added it but it didn't work.
Any help is much appreciated.
Shwe
解答
-
Thank You Ilya Tumanov ,
It was a Proxy authentication error.
You answer to check Status property of that exception and Response property for diagnostics led me to the solution.
I have solved it.
Thanks again
所有回覆
-
Thank you Ilya,
But I have included the correct path as ' http://MyComputerName/TestWebService2/TestWebService2.asmx'.
Any idea?
Regards
shwe
-
With "localhost" issue corrected, c an you reach this WS from PIE on device? If you can not, you have network issue for your (or your IT department) to fix.
-
Yes. I can reach to WebService using Pocket IE by direct typing as -
http://MyHostComputerName/TestWebService2/TestWebService2.asmx
May be there is an error or missing something in my code
public partial class PDAWebConsumerForm : Form
{
HostWebService.TestWebService2 wsTestService = new HostWebService.TestWebService2();
public PDAWebConsumerForm()
{
InitializeComponent();
wsTestService.Url = "http://MyHostComputerName/TestWebService2/TestWebService2.asmx";
}
private void buttonRequest_Click(object sender, EventArgs e)
{
//Error happens here. It does not say anything except "WebException".
textBoxResponse.Text = wsTestService.HelloWorld("From PDA");
}
}
Any suggestion please..
Shwe
-
Looks good to me… You’re no longer getting " No connection could be made because the target machine actively refused it", right? What’s the stack trace for this exception?
-
I am no longer getting that error.
Stack trace is....
at System.Web.Services.Protocols.SoapHttpClientProtocol.doInvoke()
at PDAWebConsumer.HostWebServie.TestWebService2.HelloWorld()
at.....
Thanks
shwe
-
There's only one WebException thrown from this location and it's thrown if server returns error status. You can check Status property of that exception and Response property for diagnostics.
-
Thank you Ilya,
This is the code for Exception catching..
-----------------------------------------
private void buttonRequest_Click(object sender, EventArgs e)
{
try
{
textBoxResponse.Text = wsTestService.HelloWorld("From PDA");
}
catch (WebException ex)
{
textBoxResponse.Text = " WebException : " + ex.Message;
textBoxResponse.Text +="/r/ nStackTrace = " + ex.StackTrace.ToString();
textBoxResponse.Text += "/r/ nResponse = " + ex.Response;
textBoxResponse.Text += "/r/ nStatus = " + ex.Status;
}
catch (Exception ex)
{
textBoxResponse.Text = ex.Message; ;
}
}
------------------------------------------
This is the result...
WebException : WebException
StackTrace = at System.Web.Services.Protocols.SoapHttpClientProtocol.doInvoke()
at PDAWebConsumer.HostWebService.TestWebService2.HelloWorld()
at PDAWebConsumer.PDAWebConsumerForm.buttonRequest_Click()
at System.Windows.Forms.Control.OnClick()
at System.Windows.Forms.Button.OnClick()
at System.Windows.Forms.ButtonBase.WnProc()
at System.Windows.Forms.Control._InternalWnProc()
at Microsoft.AGL.Forms.EVL.EnterMainLoop()
at System.Windows.Forms.Application.Run()
at PDAWebConsumer.Program.Main()
Response = System.Net.HttpWebResponse
Status = ProtocolError
------------------------
Any Idea?
Thanks
shwe
-
You server returned error message instead of XML data.
You should now GetResponseStream() from response and print it out to figure our why server is complaining. It would be normal HTML WEB error, e.g. " 404 Page not found".
I suspect you have security issues, though. Most likely your server is configured to serve requests from local host only and reject all others.
-
Thank You Ilya Tumanov ,
It was a Proxy authentication error.
You answer to check Status property of that exception and Response property for diagnostics led me to the solution.
I have solved it.
Thanks again