我正在使用PHP SoapClient来调用SOAP Web服务。下面是我实例化SoapClient实例的方法。
$client = new SoapClient('customer.wsdl',array("soap_version" => SOAP_1_1,"trace" => 1));
我面临的问题是,无论何时执行上述行,都会引发异常" SOAP-ERROR:解析架构:元素同时具有' type'属性和子类型"。因此,$ client变量始终保持NULL值,即未实例化。
以下是我认为导致此问题的XSD架构。
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:db="http://xmlns.oracle.com/apps/custom/soaprovider/plsql/xx_get_cust_pkg/get_customer/" targetNamespace="http://xmlns.oracle.com/apps/custom/soaprovider/plsql/xx_get_cust_pkg/get_customer/" elementFormDefault="qualified">
<element name="InputParameters">
<complexType>
<sequence>
<element name="P_CUSTOMER_NAME" type="string" db:index="1" db:type="VARCHAR2" minOccurs="0" nillable="true" />
</sequence>
</complexType>
</element>
<element name="OutputParameters">
<complexType>
<sequence>
<element name="X_MSG_STATUS" type="string" db:index="2" db:type="VARCHAR2" minOccurs="0" nillable="true" />
<element name="X_MSG_DATA" type="string" db:index="3" db:type="VARCHAR2" minOccurs="0" nillable="true" />
<element name="X_CUST" type="db:APPS.XX_GET_CUST_PKG_X3326749X1X4" db:index="4" db:type="Array" minOccurs="0" nillable="true" />
</sequence>
</complexType>
</element>
<complexType name="APPS.XX_GET_CUST_PKG_X3326749X1X5">
<sequence>
<element name="CUSTOMER_NAME" db:type="VARCHAR2" minOccurs="0" nillable="true">
<simpleType>
<restriction base="string">
<maxLength value="240" />
</restriction>
</simpleType>
</element>
<element name="PARTY_NUMBER" db:type="VARCHAR2" minOccurs="0" nillable="true">
<simpleType>
<restriction base="string">
<maxLength value="240" />
</restriction>
</simpleType>
</element>
<element name="ACCOUNT_NUMBER" db:type="VARCHAR2" minOccurs="0" nillable="true">
<simpleType>
<restriction base="string">
<maxLength value="240" />
</restriction>
</simpleType>
</element>
<element name="ACCOUNT_DESC" db:type="VARCHAR2" minOccurs="0" nillable="true">
<simpleType>
<restriction base="string">
<maxLength value="240" />
</restriction>
</simpleType>
</element>
<element name="BILL_TO_ADDRESS" db:type="VARCHAR2" minOccurs="0" nillable="true">
<simpleType>
<restriction base="string">
<maxLength value="240" />
</restriction>
</simpleType>
</element>
<element name="SHIP_TO_ADDRESS" db:type="VARCHAR2" minOccurs="0" nillable="true">
<simpleType>
<restriction base="string">
<maxLength value="240" />
</restriction>
</simpleType>
</element>
<element name="PRICE_LIST" db:type="VARCHAR2" minOccurs="0" nillable="true">
<simpleType>
<restriction base="string">
<maxLength value="240" />
</restriction>
</simpleType>
</element>
</sequence>
</complexType>
<complexType name="APPS.XX_GET_CUST_PKG_X3326749X1X4">
<sequence>
<element name="X_CUST_ITEM" type="db:APPS.XX_GET_CUST_PKG_X3326749X1X5" db:type="Struct" minOccurs="0" maxOccurs="unbounded" nillable="true" />
</sequence>
</complexType>
</schema>
我目前运行的PHP版本是 5.4.30
针对同一问题,PHP bug跟踪器上记录了一个错误https://bugs.php.net/bug.php?id=68576,其状态仍然是打开的。除了修改PHP源代码之外,请告知是否还有其他解决方法可以解决问题。