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