Search code examples
c#windowswindows-phone-8soapnusoap

Problems with nusoap in Windows Phone


I have problems with Nusoap and Windows Phone and I hope that perhaps you could help me. But first let me explain what I did:

First I created a webservice

 <?php
require_once('./lib_095/nusoap.php');
$server = new soap_server();
$server->configureWSDL('test_wsdl', 'urn:test_wsdl');
$server->wsdl->schemaTargetNamespace = 'urn:test_wsdl';


$server->register('test',               // method name      
    array('var' => 'xsd:string'),       // input parameters 
    array('return' => 'xsd:string'),    // output parameters    
    'urn:test_wsdl',                    // namespace        
    'urn:test_wsdl#test',           // soapaction       
    'rpc',                              // style            
    'literal',                          // use          
    'Test-Methode des Webservices'      // documentation        
);

function test($var) 
{
    return "test fine: $var";
}

// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);

?>

For my first test I wrote a console application in visual studio 2013:

ServiceReference1.test_servicePortTypeClient c = new ServiceReference1.test_servicePortTypeClient();

            string check = "Milburn";

            var result = c.test("Hallo");
            Console.WriteLine(result);

This little programm works fine. So I thought I could transfer the experience to Windows Phone - take the same code for that. But this didn't work. I even tried this code:

ServiceReference1.test_servicePortTypeClient c = new ServiceReference1.test_servicePortTypeClient();
            string check = "Milburn";

            var result = c.testAsync(check);
            System.Diagnostics.Debug.WriteLine("Hallo"+result);

And as a result the program returned a task. So what can I do to get a string as a result ?

Thx for your help


Solution

  • The generated service uses async methods on Windows Phone (your test changed to testAsync) so you need to await them

    var result = await c.testAsync(check);