English 中文(简体)
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.xmlsoap.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.





相关问题
Silverlight Rich text box control

Our team decided that we need our own custom Rich text box control for Silverlight app we are developing. We looked at existing controls mentioned at A good rich text control for Silverlight but ...

Silverlight ImageBrush not rendering (with Bing Map Control)

I m trying to add an image to a Pushpin instance from the Silverlight Bing Map Control, but I can t seem to get it to render (the pushpin renders fine). This is probably a general WPF question rather ...

Silverlight OpenFileDialog DoEvents equivalent

I m processing large files after they are selected by the user. My code looks like the following: if (FileDialog.ShowDialog() == true) { // process really big file } This freezes up the UI so ...

list of controls with templates in silverlight

Does anyone know where to find a list of controls that you can set the template on in Silverlight? I ve wasted several hours now trying to create control templates only to find that the control doesn ...

Silverlight, Updating the UI during processing

I have a simple silverlight multifile upload application, and i want to provide the user with some feedback, right now its only in a test phase and i dont have the webservice. Somehow i cant get the ...

Silverlight 3 - FindName returns null

This looks a bug to me.. Using Silverlight 3 and i have a user control defined in XAML and trying to access the object during runtime returns a null. <Grid> <common:CommonGridEditPanel x:...

silverlight 3 collection binding

Someone please help me understand why this binding does not work... I have a class called SelectionManager with a property called dates which is populated by a WCF service. The property is an ...

热门标签