我在php项目中写了一个soapServer。当我使用php进行soapCall时,一切都很好。但是当.net中的另一个人使用我的WSDL时,有一个错误。解决方案是什么? 我附加了错误,WSDL,SoupUi结果和函数。谢谢。中心图像描述
这是panel.wsdl
<?xml version="1.0" encoding="ISO-8859-1"?>
<definitions
targetNamespace='urn:server'
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tns='urn:server'
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<xsd:schema targetNamespace='urn:server' xmlns="urn:server">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
<xsd:complexType name="getActiveServicesResponse">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="xsd:string[]" minOccurs="1" maxOccurs="unbounded"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="getHistoryServicesResponse">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="xsd:string[]" minOccurs="1" maxOccurs="unbounded"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="getHistoryServicesAllResponse">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="xsd:string[]" minOccurs="1" maxOccurs="unbounded"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>
</types>
<message name="getActiveServicesRequest">
<part name="username" type="xsd:string" />
<part name="password" type="xsd:string" />
<part name="mobileNum" type="xsd:string" /></message>
<message name="getActiveServicesResponse">
<part name="services" type="tns:getActiveServicesResponse" /></message>
<message name="unsubscribeRequest">
<part name="username" type="xsd:string" />
<part name="password" type="xsd:string" />
<part name="mobileNum" type="xsd:string" />
<part name="serviceID" type="xsd:string" /></message>
<message name="unsubscribeResponse">
<part name="result" /></message>
<message name="getHistoryServicesAllRequest">
<part name="username" type="xsd:string" />
<part name="password" type="xsd:string" />
<part name="mobileNum" type="xsd:string" />
<part name="FromDate" type="xsd:string" />
<part name="ToDate" type="xsd:string" /></message>
<message name="getHistoryServicesAllResponse">
<part name="history" type="tns:getHistoryServicesAllResponse" /></message>
<message name="getHistoryServicesRequest">
<part name="username" type="xsd:string" />
<part name="password" type="xsd:string" />
<part name="mobileNum" type="xsd:string" />
<part name="serviceID" type="xsd:string" />
<part name="FromDate" type="xsd:string" />
<part name="ToDate" type="xsd:string" /></message>
<message name="getHistoryServicesResponse">
<part name="history" type="tns:getHistoryServicesResponse" /></message>
<portType name="iPanelPortType">
<operation name="getActiveServices">
<input message="tns:getActiveServicesRequest"/>
<output message="tns:getActiveServicesResponse"/>
</operation>
<operation name="unsubscribe">
<input message="tns:unsubscribeRequest"/>
<output message="tns:unsubscribeResponse"/>
</operation>
<operation name="getHistoryServicesAll">
<input message="tns:getHistoryServicesAllRequest"/>
<output message="tns:getHistoryServicesAllResponse"/>
</operation>
<operation name="getHistoryServices">
<input message="tns:getHistoryServicesRequest"/>
<output message="tns:getHistoryServicesResponse"/>
</operation>
</portType>
<binding name="iPanelBinding" type="tns:iPanelPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getActiveServices">
<soap:operation soapAction="urn:server#getActiveServices" style="rpc"/>
<input><soap:body use="encoded" namespace="urn:server" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
<output><soap:body use="encoded" namespace="urn:server" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
</operation>
<operation name="unsubscribe">
<soap:operation soapAction="urn:server#unsubscribe" style="rpc"/>
<input><soap:body use="encoded" namespace="urn:server" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
<output><soap:body use="encoded" namespace="urn:server" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
</operation>
<operation name="getHistoryServicesAll">
<soap:operation soapAction="urn:server#getHistoryServicesAll" style="rpc"/>
<input><soap:body use="encoded" namespace="urn:server" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
<output><soap:body use="encoded" namespace="urn:server" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
</operation>
<operation name="getHistoryServices">
<soap:operation soapAction="urn:server#getActiveServices" style="rpc"/>
<input><soap:body use="encoded" namespace="urn:server" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
<output><soap:body use="encoded" namespace="urn:server" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
</operation>
</binding>
<service name="iPanel">
<port name="iPanelPort" binding="tns:iPanelBinding">
<soap:address location="http://37.130.202.161/integratedPanel?wsdl"/>
</port>
</service>
</definitions>
功能
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Exception;
use App\Notification;
use App\LogNotification;
use Log;
class ServiceBinding extends Controller
{
public function getActiveServices($username,$password,$mobilNum)
{
return "hello";
}
public function unsubscribe($username,$password,$mobilNum,$serviceID)
{
return "hello";
}
public function getHistoryServicesAll($username,$password,$mobilNum,$toDate,$fromDate)
{
return "hello";
}
public function getHistoryServices($username,$password,$mobilNum,$serviceID,$toDate,$fromDate)
{
return "hello";
}
}
?>
动作肥皂
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Exception;
use Log;
class IntegratedPanelController extends Controller
{
public function soap() {
try{
ini_set('soap.wsdl_cache_enabled', 0);
ini_set('soap.wsdl_cache_ttl', '0');
$server = new \SoapServer('/home/sysadmin/VAS_mci/public/wsdl/panel.wsdl', array('cache_wsdl' => WSDL_CACHE_NONE));
$server->setClass("App\Http\Controllers\ServiceBinding");
try {
$server->handle();
}
catch (Exception $e) {
echo 'IntegratedPanelController.........'. $e->getMessage();
log::info($e->getMessage());
$server->fault('Sender', $e->getMessage());
}
// echo "SOAP Server started";
}
catch (Exception $exception){
echo 'IntegratedPanelController.........'.$exception->getMessage();
log::info($exception->getMessage());
return $exception->getMessage();
}
}
}
答案 0 :(得分:0)
关于标准的好处是有很多可供选择的。在XML方面,.Net和Java都有不同的标准。由于XML非常灵活,因此即使创建新标准也很容易。一个与其他标准不相容的。
您的WSDL不符合WSI,因此无法保证它可以在您的工具包之外的任何工作中使用。 WSI是XML的标准,它是如何在SOAP调用中表示的,因此如果您希望您的服务能够使用您需要的所有内容来确保它是WSI投诉。
我在SOAP UI中运行了WSI合规性测试但失败了。您也使用RPC类型调用,这在一些意见已过时。因此,我们需要确保我们的WSDL文件尽可能符合WSI,以避免此类问题。
一个简单的例子可以澄清我们为什么这样做。编程中的null
概念是null未定义它没有值。如何在XML中指定NO VALUE?
让我们假设我们有一个只有名字的客户XML。如何指定NULL Name值?我可以做以下其中一项:
示例1:
<customer>
<name/>
</customer>
示例2:
<customer/>
示例3:
<customer>
<name nullable="true" />
</customer>
因此,您可以在这里看到我们有三种在XML中表示NULL的标准,哪一个是正确的?它们在某些方面都是正确的。取决于你如何解释它。
有一点很奇怪的是你如何定义数组。当我在液体XML工作室中打开您的WSDL时,以下行无效:
<xsd:complexType name="getHistoryServicesResponse">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="xsd:string[]" maxOccurs="unbounded"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
这会产生以下错误:
(15:9) Critical The 'maxOccurs' attribute is not supported in this context.
(15:9) Critical The 'minOccurs' attribute is not supported in this context.
我删除了最小和最大值,然后我遇到了另一个错误。这包含了主要问题:
Schema Error Undefined complexType 'http://schemas.xmlsoap.org/soap/encoding/:Array' is used as a base for complex type restriction.
基本上,当您对PHP有效时,定义WSDL的方式对其他语言(如.Net或Java)无效。问题在于您定义数组的方式。
这个问题会告诉你更多Error Consuming a RPC/Encoded SOAP web service in .NET。我确实意识到这不是您正在寻找的答案,但希望它能帮助您解决问题。