1

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

aperez
  • 121
  • 1
  • 13
  • I wonder if you could provide a little more information. It sounds like you are trying unsuccessfully to add a service reference in your client to your ws_test.php service. Are you doing this with the Add Service Reference functionality in Visual Studio? What happens when you try that? The client/endpoint/@address should not be referring to a ?wsdl URL, that is an ad hoc protocol for finding a metadata exchange endpoint (/mex has since become the standard for that). Is there any chance you can host a sample php service on a public server so we can contruct a working sample client? – Visual Stuart Nov 08 '11 at 01:13
  • Here's a blog post, [Testing the NuSOAP Webservice in C#](http://www.hirdweb.com/2010/08/15/testing-the-nusoap-webservice/) that seems to do a good job of explaining how to add a service reference to a php service in NuSOAP. How does that compare with what you have been trying? – Visual Stuart Nov 08 '11 at 01:32
  • The example that I spend working, but when I do as required asynchronous Windows Phone stops working – aperez Nov 08 '11 at 08:33

2 Answers2

1

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

competent_tech
  • 44,465
  • 11
  • 90
  • 113
aperez
  • 121
  • 1
  • 13
0

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.

MatthieuGD
  • 4,552
  • 2
  • 30
  • 29
  • With all due respect, I don't think that changing service technology is required. WCF configuration, especially configuring a client, in not particularly difficult. And WCF 4 does a reasonably nice job with REST and JSON, so for simple tasks it is not necessary to add in RESTSharp or JSON.net. Those are fine libraries, but pretty much unrelated to the problem as far as I can see. Perhaps @Gandark can shed more light on the problem being experienced. – Visual Stuart Nov 08 '11 at 01:20
  • I need to use SOAP with PHP, the point is that everything works fine, the web service makes its function but there is a configuration problem that can not see when trying to return the response (endpoint address) – aperez Nov 08 '11 at 08:00
  • @VisualStuart WCF it's so simple that when you get an error you have to go to SO to understand it ... Yeah right and WCF 4 (Client) is so simple that MS choose to re-rewrite it for .NET framework 4.5 (http://wcf.codeplex.com/wikipage?title=WCF HTTP). And BTW there's no XML configuration for thoses librairies because you don't need it. WCF is overkilled and I was trying to point it out before going further. – MatthieuGD Nov 08 '11 at 16:02
  • Hello @Matthieu, Gandark's question is not an appropriate time or place to discuss the pros and cons of WCF (there are many on both sides of the coin.) He's explained that his solution is contrained to being a client of SOAP services. I'd like to see him be successful with that, and perhaps I can contribute to his success. I think that's why we're all here. – Visual Stuart Nov 08 '11 at 19:04
  • In the first paragraph he said "I've adapted the web service to work with Windows Phone and everything seems fine." If he adapted once it seems to me that he can adapt to work with other stacks server-side. I've some experience with Windows Phone and WCF and I can tell that WCF is not a good solution in this particular context. If now he can't change at all the server-side service maybe we can help with more details about the code used client-side ? – MatthieuGD Nov 08 '11 at 19:13