基于WS-Notification WSDL创建SOAP Web服务

时间:2019-05-10 21:12:00

标签: java web-services soap xsd wsdl

我需要创建一个接收SOAP请求并发回确认响应的SOAP Web服务。我希望这项服务尽可能轻便。它可以用Java或Python编写。

已为我提供了.WSDL和与之匹配的.XSD。该服务是WS-Notification标准的简化实现。我无法控制这些文件的内容。

WSDL不包含任何服务定义。

这是WSDL:

<?xml version="1.0" encoding="utf-8"?>

<wsdl:definitions name="WS-BaseNotification"
      targetNamespace="http://www.example.com/wsdl/notification"
      xmlns:wsntw="http://www.example.com/wsdl/notification"
      xmlns:wsnt="http://www.example.com/schema/notification"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">

    <!-- ===================== Types Definitions ====================== -->
    <wsdl:types>
        <xsd:schema>
            <xsd:import
             namespace="http://www.example.com/schema/notification" 
             schemaLocation="Notification.xsd"/>
        </xsd:schema>
    </wsdl:types>

    <!-- ================ NotificationConsumer::Notify ================ 
      Notify(
        NotificationMessage
          (SubscriptionReference, TopicExpression, ProducerReference,
           Message)*
      returns: Ack
    -->

    <wsdl:message name="Notify">
        <wsdl:part name="Notify" element="wsnt:Notify"/>
    </wsdl:message>
    <wsdl:message name="Acknowledge">
        <wsdl:part name="Acknowledge" element="wsnt:Acknowledge"/>
    </wsdl:message>
    <wsdl:message name="Fault">
        <wsdl:part name="Fault" element="wsnt:Fault"/>
    </wsdl:message>

    <!-- ========= NotificationConsumer PortType Definition =========== -->
    <wsdl:portType name="NotificationConsumer">
        <wsdl:operation name="Notify">
            <wsdl:input message="wsntw:Notify" />
            <wsdl:output message="wsntw:Acknowledge" />
            <wsdl:fault message="wsntw:Fault" name="fault1"/>
        </wsdl:operation>
    </wsdl:portType>

</wsdl:definitions>

这是XSD:

<?xml version="1.0" encoding="UTF-8"?>

<xsd:schema xmlns:wsnt="http://www.example.com/schema/notification" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/schema/notification" elementFormDefault="qualified" attributeFormDefault="unqualified" version="0.2">

    <!--This XSD defined the types and elements used for the ERCOT Notification interfaces-->
    <!---->
    <!-- ================== Message Helper Types  ===================== -->
    <xsd:complexType name="NotificationMessageHolderType">
        <xsd:sequence>
            <xsd:element name="Message">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:any namespace="##any" processContents="lax"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:element name="NotificationMessage" type="wsnt:NotificationMessageHolderType"/>
    <!-- ========== Message Types for NotificationConsumer  =========== -->
    <xsd:element name="Notify">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="wsnt:NotificationMessage" maxOccurs="unbounded"/>
                <xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="Acknowledge">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="ReplyCode" type="xsd:string" minOccurs="0"/>
                <xsd:element name="Timestamp" type="xsd:dateTime" minOccurs="0"/>
                <xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="Fault">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="FaultCode" type="xsd:string" minOccurs="0"/>
                <xsd:element name="Timestamp" type="xsd:dateTime" minOccurs="0"/>
                <xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>

如何从这两个文件创建Web服务?

我尝试了以下操作:

  • 在Eclipse中,创建一个动态Web项目并导入一个Web服务。我收到一条错误消息,提示“ Notification.wsdl没有服务元素。”
  • 使用WSDL2Java:我收到一条错误消息,提示“ Notification.wsdl没有定义任何服务”

我对如何使用Java或Python实施此服务感到非常困惑。

非常感谢您的帮助!

0 个答案:

没有答案