问题描述
现在我要用java测试调用php写的webservice接口,我在myeclipse中新建webservice client过程中,添加WSDL URL时,无法生成代理类了!提示:WSDL file has validation errors. Code generation may failsrc-resolve.4.2: Error resolving component 'SOAP-ENC:Array'.It was detected that 'SOAP-ENC:Array' is in namespace 'http://schemas.xmlsoap.org/soap/encoding/',but componets from this namespace are not referenceable from schema document 'http://....'。问题补充:这是wsdl: <?xml version="1.0" encoding="UTF-8" ?> - <wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schema.example.com" targetNamespace="http://schema.example.com">- <wsdl:types>- <xsd:schema targetNamespace="http://schema.example.com">- <xsd:complexType name="GetListArray">+ <xsd:complexContent>- <xsd:restriction base="SOAP-ENC:Array"> <xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:GetList[5]" /> </xsd:restriction> </xsd:complexContent> </xsd:complexType>- <xsd:complexType name="GetList">- <xsd:all> <xsd:element name="apikey" type="xsd:string" /> <xsd:element name="code" type="xsd:string" /> <xsd:element name="keyword" type="xsd:string" /> <xsd:element name="name" type="xsd:string" /> <xsd:element name="price" type="xsd:float" /> </xsd:all> </xsd:complexType> </xsd:schema> </wsdl:types>- <message name="getRequest"> <part name="apikey" type="xsd:string" /> <part name="keyword" type="xsd:string" /> </message>- <message name="getResponse"> <part name="getReturn" type="tns:GetListArray" /> </message>- <wsdl:portType name="TestPortType">- <wsdl:operation name="get"> <wsdl:input message="tns:getRequest" /> <wsdl:output message="tns:getResponse" /> </wsdl:operation> </wsdl:portType>- <binding name="TestBinding" type="tns:TestPortType"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" /> - <wsdl:operation name="get"> <soap:operation soapAction="http://test.cnfol.com/project/wshelper/service.php?class=Test&method=get" style="rpc" /> - <wsdl:input> <soap:body use="encoded" namespace="http://schema.example.com" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /> </wsdl:input>- <wsdl:output> <soap:body use="encoded" namespace="http://schema.example.com" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /> </wsdl:output> </wsdl:operation> </binding>- <wsdl:service name="Test">- <wsdl:port name="TestPort" binding="tns:TestBinding"> <soap:address location="http://test.cnfol.com/project/soap/TestService.php" /> </wsdl:port> </wsdl:service> </wsdl:definitions>
解决方案
opensky85 写道你好!有空吗?帮我看看《PHP写的webservice接口,为什么用myeclipse无法生成代理类?》这个问题,我对问题进行了补充,希望你能抽空给我回答下,很希望能得到你的回答!谢谢!看了一下,你的这个定义<xsd:complexType name="GetListArray">名字是不是有问题,WSDL规定 阵列名称类型必须是「ArrayOf」这个开头,你改成 ArrayOfGetListArray 试试
解决方案二:
现在看,你两边的命名控件好像不匹配具体没有代码没法判断,你自己好好查一下命名空间先