我在 Delphi 2010 中生成 WSDL 时遇到问题。我写了一个示例并复制了生成的 WSDL 文件:
<?xml version="1.0"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema" name="IHalloWeltIntfservice" targetNamespace="http://www.micos.de/namespace/" xmlns:tns="http://www.micos.de/namespace/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:ns1="http://www.borland.com/namespaces/Types" xmlns:ns2="urn:XSTypen" xmlns:ns3="urn:uHalloWeltIntf">
<types>
<xs:schema targetNamespace="urn:uHalloWeltIntf" xmlns="urn:uHalloWeltIntf">
<xs:complexType name="EHalloWelt">
<xs:sequence>
<xs:element name="KundenId" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</types>
<message name="HoleHalloWeltAlsXML2Request">
<part name="InstitutionId" type="xs:int"/>
<part name="KundenId" type="xs:int"/>
</message>
<message name="HoleHalloWeltAlsXML2Response">
<part name="return" type="xs:string"/>
</message>
<message name="HoleHalloWeltAlsXML2fault0">
<part name="EHalloWelt" type="ns3:EHalloWelt"/>
</message>
<portType name="IHalloWeltIntf">
<operation name="HoleHalloWeltAlsXML">
<input message="tns:HoleHalloWeltAlsXML2Request"/>
<output message="tns:HoleHalloWeltAlsXML2Response"/>
<fault name="EKeineVitalwerteVorhanden" message="tns:HoleHalloWeltAlsXML2fault0"/>
</operation>
</portType>
<binding name="IHalloWeltIntfbinding" type="tns:IHalloWeltIntf">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="HoleHalloWeltAlsXML">
<soap:operation soapAction="urn:uHalloWeltIntf-IHalloWeltIntf#HoleHalloWeltAlsXML" style="rpc"/>
<input>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:uHalloWeltIntf-IHalloWeltIntf"/>
</input>
<output>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:uHalloWeltIntf-IHalloWeltIntf"/>
</output>
<fault>
<soap:fault use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:uHalloWeltIntf-IHalloWeltIntf"></soap:fault>
</fault>
</operation>
</binding>
<service name="IHalloWeltIntfservice">
<port name="IHalloWeltIntfPort" binding="tns:IHalloWeltIntfbinding">
<soap:address location="http://localhost:1024/soap/IHalloWeltIntf"/>
</port>
</service>
</definitions>
起初该文件看起来不错,但如果我尝试将其导入 NetBeans,ant wscompile 目标会告诉我绑定(bind) block 中缺少属性。 soap:fault 元素没有 name 属性。在我看来,该属性在 WSDL 定义中是必需的。这是 Delphi 中的错误还是有任何方法可以使 WSDL 在其他语言中工作?
最佳答案
Delphi 2010 生成的 WSDL 使用 RPC 编码的 SOAP 样式(参见 NetBeans 7.0 and JAX-RPC Web Services)。
如果您手动修复 WSDL 中的错误,NetBeans 7.2 中的 SAX-RPC 导入器会生成所需的 Java 类:
<fault name="EKeineVitalwerteVorhanden">
<soap:fault name="EKeineVitalwerteVorhanden" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:uHalloWeltIntf-IHalloWeltIntf"></soap:fault>
</fault>
发电机输出:
ant -f C:\\Users\\... test.wsdl4-client-wscompile
init:
wscompile-init:
test.wsdl4-client-wscompile:
Copying 1 file to C:\Users\...\build\generated-sources\jax-rpc\wsdl
Warnung: Verarbeitung von WS-I-nicht-entsprechendem Vorgang "HoleHalloWeltAlsXML" mit RPC-Stil und SOAP-kodiert
Warnung: R2716/R2726 WSI-BasicProfile Ver. 1.0, Namespace-Attribut unzulässig in doc/lit oder rpc/lit für soapbind:fault: "EKeineVitalwerteVorhanden"
BUILD SUCCESSFUL (total time: 2 seconds)
关于delphi - SOAP:Delphi 2010 生成的 WSDL 定义中的错误错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15062380/