views:

418

answers:

3

EDIT: After some research, I found the answer to the problem (at least it works for my particular situation). Instead of the register call noted down below, I am now using the following call:

$soap->register(
                'MyFunction',
                array('inputData' => 'xsd:string'),
                array('outputData' => 'xsd:string'),
                $namespace,
                $namespace . "#MyFunction",
                "rpc",
                "literal",
                "My description.");

I guess the "rpc" and "literal" arguments are the key to the success. Hopefully this will help some other users facing the same problem.


I have a problem with a new project, where a silverlight application is to request data from a NuSoap-service. As this integration is rather new to me and unfortunately not many resources concerning this topic can be found on the internet (none addressing my problem at least), I hope that someone can point me into the correct direction.

The NuSoap-part is implemented like this:

<?php
   require_once('../soap/nusoap/nusoap.php');

   $namespace = "http://127.0.0.1/adminSoap";
   $soap = new Soap_Server();
   $soap->configureWSDL('MyService', $namespace);
   $soap->wsdl->schemaTargetNameSpace = $namespace;
   $soap->soap_defencoding = 'utf-8';

   $soap->register(
                'MyFunction',
                array('inputData' => 'xsd:string'),
                array('outputData' => 'xsd:string'),
                $namespace

   );

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

   function MyFunction($inputData)
   {
       return "ok";
   }

?>

I then add a web reference to this service and get the dialog where I can select the service, its ServicePortType as well as "MyFunction".

If I generate the reference however, I would assume to find automatically generated asynchronous messages for MyFunction (i.e. MyFunctionAsync and the MyFunctionCompleted.event). These do not exist.

What could I be doing wrong. Here's the code that sets up the client:

ServiceReference4.MyServicePortTypeClient client = new SilverlightTest1.ServiceReference4.MyServicePortTypeClient();

Any ideas why the asynchronous method is not available?

Here's the generated WSDL, if that's of any help, btw (hyphens due to copy/paste from IE):

<definitions targetNamespace="http://127.0.0.1/adminSoap"&gt;
−
<types>
−
<xsd:schema targetNamespace="http://127.0.0.1/adminSoap"&gt;
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/&gt;
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/&gt;
</xsd:schema>
</types>
−
<message name="MyFunctionRequest">
<part name="affiliate" type="xsd:string"/>
</message>
−
<message name="MyFunctionResponse">
<part name="result" type="xsd:string"/>
</message>
−
<portType name="MyServicePortType">
−
<operation name="MyFunction">
<input message="tns:MyFunctionRequest"/>
<output message="tns:MyFunctionResponse"/>
</operation>
</portType>
−
<binding name="MyServiceBinding" type="tns:MyServicePortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/&gt;
−
<operation name="MyFunction">
<soap:operation soapAction="http://127.0.0.1/magento/adminSoap/SoapStatsService.php/MyFunction" style="rpc"/>
−
<input>
<soap:body use="encoded" namespace="http://127.0.0.1/adminSoap" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/&gt;
</input>
−
<output>
<soap:body use="encoded" namespace="http://127.0.0.1/adminSoap" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/&gt;
</output>
</operation>
</binding>
−
<service name="MyService">
−
<port name="MyServicePort" binding="tns:MyServiceBinding">
<soap:address location="http://127.0.0.1/magento/adminSoap/SoapStatsService.php"/&gt;
</port>
</service>
</definitions>
A: 

I working on a similar problem. I was using Zend_Soap (which just wraps the PHP SOAP extension), and using a Silverlight Service Reference to connect to it. It seems that the Silverlight Service implementation cannot make us of soap-encoded operations. If you look at the WSDL under each has an and . In those tags are the the attributes that damn us both to frustration. The use="encoded" and encodingStyle="blah, blah" attributes.

I now know that Zend_Soap will only make bindings that use soap-encoding. I'm not sure yet about nuSoap.

If you can change the PHP backend, you might look into Midnight Coders WebORB for PHP and Silverlight. It includes a solution for both the server and the client that work together. It is available for free for certain circumstances. Due to licensing issues, I don't I'll be able to us it.

Charles
Hi Charles, thank you very much for the answer.I have been looking into this a little bit longer and think I have found a solution (at least for my particular problem). I will edit it into my question right away.
Grimtron
A: 

Your problem was exactly my problem. Thanks for saving me a lot of time.

Keith
A: 

Hi Grimtron. do you have any solution for returning array of complex type. I want to consume this service in silverlight 4. Please help me out.

Rohit Raisinghani
Has been some time since I worked with this - as far as I remember I just encoded the data as a proprietary string and parsed it back into an object in the SL application.
Grimtron