Search code examples
phpweb-serviceswindows-phone-7wsdlcommunicationexception

CommunicationException with Windows Phone 7 and PHP Web Service


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


Solution

  • 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