2

编辑:经过一番研究,我找到了问题的答案(至少它适用于我的特定情况)。我现在使用的是以下调用,而不是下面提到的注册调用:

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

我猜“rpc”和“literal”参数是成功的关键。希望这将帮助其他一些面临同样问题的用户。


我有一个新项目的问题,其中silverlight 应用程序要从NuSoap 服务请求数据。由于这种集成对我来说相当新,不幸的是在互联网上找不到很多关于这个主题的资源(至少没有解决我的问题),我希望有人能指出我正确的方向。

NuSoap 部分的实现如下:

<?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";
   }

?>

然后,我添加对该服务的 Web 引用并获得可以选择服务、其 ServicePortType 以及“MyFunction”的对话框。

但是,如果我生成引用,我会假设为 MyFunction 找到自动生成的异步消息(即 MyFunctionAsync 和 MyFunctionCompleted.event)。这些不存在。

我可能做错了什么。这是设置客户端的代码:

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

任何想法为什么异步方法不可用?

这是生成的 WSDL,如果有任何帮助,顺便说一句(由于从 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>
4

1 回答 1

0

我正在处理类似的问题。我使用的是 Zend_Soap(它只是包装了 PHP SOAP 扩展),并使用 Silverlight 服务引用来连接它。Silverlight 服务实现似乎无法让我们使用肥皂编码的操作。如果你看下每个 WSDL 都有一个和 . 在这些标签中是使我们都感到沮丧的属性。use="encoded" 和 encodingStyle="blah, blah" 属性。

我现在知道 Zend_Soap 只会制作使用肥皂编码的绑定。我还不确定nuSoap。

如果您可以更改 PHP 后端,则可以查看 Midnight Coders WebORB for PHP 和 Silverlight。它包括一起工作的服务器和客户端的解决方案。在某些情况下可以免费使用。由于许可问题,我无法使用它。

于 2009-12-07T05:32:08.123 回答