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



Answer this question

WebService calling from Pocket PC

  • leightonr

    hi, try to do this,

    when u create the webservice using VS 2005 right then while selecting the ne project select the http option in the file path, coz, anytime time u run the service u would get different generated port number associated with it. in ur case

    "http://172.19.57.182:100/MyWebService/Service.asmx";

    so just provide as

    http://172.19.57.182/MyWebService/Service.asmx while creating the project so u wont get the port number and then try.


    and 1 another thing, dnt provide the url, just when consuming the service use "add web reference"

    by right clicking on the project name.


  • sbrunnsen

    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



  • Rick Hill

    Thank you Ilya,
    But I have included the correct path as 'http://MyComputerName/TestWebService2/TestWebService2.asmx'.

    Any idea

    Regards
    shwe


  • Istvan137

    Hi Shwe,

    I am getting the same for my PPC application can u please help me how did u solve it using Proxy Authentication,

    As there will be different proxy setting on different client device so how can i generalize the soln for all.

    Thanks,

    Bks



  • Carl Daniel

  • Sean ORegan

    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.



  • Marcos Martins

    With "localhost" issue corrected, can you reach this WS from PIE on device If you can not, you have network issue for your (or your IT department) to fix.



  • B.F.Rej

    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



  • Jay433882

    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.



  • craig kelly-soens xpectworld.net

    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


  • Crane101

    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



  • tickling

    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



  • Fire3.san

    Hai all,

    I am getting a error while connecting to webservice through pocket pc. I tried serveral ways to solve but unable to do it. I saw the similar error in forums but i found no help. Below i have mentioned my code and catch block stack trace and status of the request and response.

    Any help will be highly appreciated.

    TestService.Service obj;

    obj = new TestService.Service();

    try

    {

    obj.Url = "http://172.19.57.182:100/MyWebService/Service.asmx";

    txtName.Text = obj.HelloWorld();

    }


    catch (System.Net.WebException ex)
    {
    txtName.Text = "WebException:=" + ex.Message;
    txtName.Text+= "\r\nStackTrace:=" + ex.StackTrace.ToString();
    txtName.Text+= "\r\nResponse:=" + ex.Response;
    txtName.Text+= "\r\nStatus:= " + ex.Status;
    }

    ex.Message
    "Could not establish connection to network."
    ex.StackTrace.Tostring()
    'string' does not contain a definition for 'Tostring'
    ex.StackTrace
    "at System.Net.HttpWebRequest.finishGetResponse()\r\nat System.Net.HttpWebRequest.GetResponse()\r\nat System.Web.Services.Protocols.WebClientProtocol.GetWebResponse()\r\nat System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse()\r\nat System.Web.Services.Protocols.SoapHttpClientProtocol.doInvoke()\r\nat System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke()\r\nat MyPc.TestService.Service.HelloWorld()\r\nat MyPc.Form1.button1_Click()\r\nat System.Windows.Forms.Control.OnClick()\r\nat System.Windows.Forms.Button.OnClick()\r\nat System.Windows.Forms.ButtonBase.WnProc()\r\nat System.Windows.Forms.Control._InternalWnProc()\r\nat Microsoft.AGL.Forms.EVL.EnterMainLoop()\r\nat System.Windows.Forms.Application.Run()\r\nat MyPc.Program.Main()\r\n"
    ex.Response
    null
    > ex.Status
    ConnectFailure



  • s441

    hi,

    I m facing the same problem, i tried to resolve through proxy server settings, firewall settings off, but no solution. I m having the same error only difference is "Status = Connect Failure"

    Please help needed.




  • WebService calling from Pocket PC