×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    1

    Unhappy Got error on adding php web service in windows phone 7

    HI,

    i am beginner in windows phone 7. today i create one application in windows phone 7. and develop hello world app. now i want to start with my main app. and i start to add PHP web service reference. but it show me error.

    Note : also one thing this service is running good in iphone app and android app.

    i follow below steps to add service.

    1) right click on add web refrence
    2) paste my php web service url and press go button
    3) and got below error

    The HTML document does not contain Web service discovery information.
    Metadata contains a reference that cannot be resolved: 'http://mydomain.com/webservices/getLogin.php'.
    The content type text/html of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 80 bytes of the response were: '{"userLogin":{"status":"NO","error":"Please enter valid user name \/ password"}}'.
    If the service is defined in the current solution, try building the solution and adding the service reference again.

    i search a lot but i didnt get proper solution. please help me to resolve this issue. how to add php service.

    Thanks in advance.
    Last edited by WS7Dev; 2012-10-02 at 11:12.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,750

    Re: Got error on adding php web service in windows phone 7

    PHP refers a lot of things as 'Web service' based on this page: http://php.net/manual/en/refs.webservice.php, so it may be worth pointing out that Microsoft platforms default to the SOAP-based variant when talking about Web service.

  3. #3
    Regular Contributor
    Join Date
    Jan 2009
    Location
    India
    Posts
    138

    Re: Got error on adding php web service in windows phone 7

    I would suggest you to go for REST service mechanism to communicate with the .php service, you may have to change the server side code as well as client.

    You have to send parameters with the php service url and get the response accordingly.

    Here is the service invoke code for the same.

    Code:
     public class NetworkService
        {
            string strResponse = string.Empty;
    
            public NetworkService()
            {
    
            }
    
    
            public string SendWebRequest(string strQueryString)
            {
                try
                {
                    string strServiceUrl = string.Format("http://mydomain.com/webservices/getLogin.php?userinfo={0}", strQueryString);
                    HttpWebRequest request = null;
                    request = (HttpWebRequest)HttpWebRequest.Create(new Uri(strServiceUrl));
                    IAsyncResult asynchronousResult = request.BeginGetResponse(new AsyncCallback(ReadCallback), request);
    
                    return strResponse;
                }
                catch
                {
                    throw;
                }
            }
    
    
            private void ReadCallback(IAsyncResult asynchronousResult)
            {
                try
                {
                    HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
                    HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult);
    
                    using (StreamReader streamReader1 = new StreamReader(response.GetResponseStream()))
                    {
                        strResponse = streamReader1.ReadToEnd();
                    }
                }
                catch
                {
                    throw;
                }
    
            }
        }
    To invoke from client side.

    Code:
     NetworkService oNetworkService = new NetworkService();
     oNetworkService.SendWebRequest("UserName_Password");
    Hope it helps.
    Pavan Pareta
    Sr. Software Engineer
    http://windows-mobile-dev.blogspot.com

  4. #4
    Registered User
    Join Date
    Jun 2008
    Location
    Port Elizabeth, South Africa
    Posts
    37

    Re: Got error on adding php web service in windows phone 7

    Hi,

    It looks like you will also need to handle the JSON response from that PHP web service after calling it. Windows Phone does not handle the conversion of the JSON into a format you can easily reference in code. I've used JSON.NET in a WP7.5 app and it worked very well: http://json.codeplex.com/.

    Regards,
    Stephen

  5. #5
    Registered User
    Join Date
    Jan 2012
    Posts
    6

    Re: Got error on adding php web service in windows phone 7

    If you like, you can use Cordova and make HTML5 based apps that integrates with your PHP code. (For portability reasons, this is the best tip)
    But if you love native, you have to make a REST request from your server.

Similar Threads

  1. SOAP web service request with credentials for Windows Phone 7
    By sreerajvr in forum Windows Phone General
    Replies: 16
    Last Post: 2012-04-03, 10:17
  2. Connect to phone from windows service
    By stealth117 in forum PC Suite API and PC Connectivity SDK
    Replies: 4
    Last Post: 2008-09-27, 19:32
  3. No Phone Connected in Windows Service
    By windsocks in forum PC Suite API and PC Connectivity SDK
    Replies: 0
    Last Post: 2006-01-03, 10:02
  4. Windows XP service pack2 ( nokia suite 2.2 error)
    By j2mePraveen in forum Mobile Java Tools & SDKs
    Replies: 2
    Last Post: 2005-03-07, 06:20
  5. Error running as Windows Service
    By pkgal in forum PC Suite API and PC Connectivity SDK
    Replies: 4
    Last Post: 2003-10-18, 09:21

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×