开发者

Silverlight and NuSoap

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">
−
<types>
−
<xsd:schema targetNamespace="http://127.0.0.1/adminSoap">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
</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.xml开发者_JAVA技巧soap.org/soap/http"/>
−
<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/"/>
</input>
−
<output>
<soap:body use="encoded" namespace="http://127.0.0.1/adminSoap" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
−
<service name="MyService">
−
<port name="MyServicePort" binding="tns:MyServiceBinding">
<soap:address location="http://127.0.0.1/magento/adminSoap/SoapStatsService.php"/>
</port>
</service>
</definitions>


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜