CommunicationException with Windows Phone 7 and PHP Web Service

897 views Asked by At

I have a PHP web service built with the NuSOAP library. I've adapted the web service to work with Windows Phone and everything seems fine.

The problem is when I receive the reply, I get a CommunicationException. I think that is the url of the endpoint which does not recognize ?wsdl.

I searched information about it but I can not find anything to solve it.

My code is as follows:

       private void button1_Click(object sender, RoutedEventArgs e)
       {
        var test = new TS.TestWSDLPortTypeClient();
        test.sumarCompleted += test_sumarCompleted;
        test.sumarAsync(3, 4);
       }

      void test_sumarCompleted(object sender, TS.sumarCompletedEventArgs e)
      {
      MessageBox.Show(e.Result.ToString();
      }

And my .ClientConfig

<configuration>
             <system.serviceModel>
                <bindings>
                   <basicHttpBinding>
                    <binding name="TestWSDLBinding" maxBufferSize="2147483647"                                      maxReceivedMessageSize="2147483647">
                     <security mode="None" />
                 </binding>
             </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://192.168.1.38/ws_test.php" binding="basicHttpBinding"
                bindingConfiguration="TestWSDLBinding" contract="TestWSDL.TestWSDLPortType"
                name="TestWSDLPort" />
              </client>
              </system.serviceModel>
               </configuration>

I have also tested:

<endpoint address="http://192.168.1.38/ws_test.php?wsdl"...

I have also tested with a domain name, ip: 127.0.0.1, others port, etc.

The PHP code is:

#DeclaraciĆ³n del servidor nusoap
$server = new soap_server();
$server->configureWSDL("TestWSDL","urn:TestWSDL", "http://libreriacloud.sytes.net/ws_monster/ws_test.php?wsdl");
$server->soap_defencoding = 'UTF-8'; 

#Registro de la Funcion Sumar
$server->register(
    'sumar',
    array(
        'x' => 'xsd:int',
        'y' => 'xsd:int'
        ),
    array('return' => 'xsd:int'),
    'urn:TestWSDL',
    'urn:TestWSDL/sumar',
    'document',
    'literal',
    'Suma dos datos'
);

function sumar($x, $y)
{
    return $x+$y;
}

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA); 

The WSDL url is: http://libreriacloud.sytes.net/ws_monster/ws_test.php

2

There are 2 answers

0
aperez On BEST ANSWER

I solved my problem. Instead of 'document' to''had put 'document' because he had seen in svc, I went crazy to find an answer in the end went to trial and error.

The server code the solution:

#DeclaraciĆ³n del servidor nusoap
$server = new soap_server();
$server->configureWSDL("TestWSDL","urn:TestWSDL", "http://libreriacloud.sytes.net/ws_monster/ws_test.php?wsdl");
$server->soap_defencoding = 'UTF-8'; 

#Registro de la Funcion Sumar
$server->register(
    'sumar',
    array(
        'x' => 'xsd:int',
        'y' => 'xsd:int'
        ),
    array('return' => 'xsd:int'),
    'urn:TestWSDL',
    'urn:TestWSDL/sumar',
    '',
    'literal',
    'Suma dos datos'
);

function sumar($x, $y)
{
    return $x+$y;
}

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA); 

It's the same, but under

'urn:TestWSDL/sumar',

I put single quotes

5
MatthieuGD On

It seems that you have some control on the webservice. If so, I would stay away from SOAP and go for simpler technology stack like REST with JSON. Why? Because WCF is powerful but hard to debug/setup etc.

There's a lot of good librairies out there to work with JSON on .NET: http://json.codeplex.com/ and for REST if you need more than the WebClient/WebRequest): http://restsharp.org/

Sorry if it's not the answer you expected but I have work a lot with WCF to know when NOT using it.