wsdl扩展名添加新属性

时间:2015-05-28 03:24:37

标签: java web-services soap wsdl

我正在做与WSDL相关的项目,我想在我的WSDL文件中添加新属性。 WSDL的主要结构是:

<definitions>

<types>
  data type definitions........
</types>

<message>
  definition of the data being communicated....
</message>

<portType>
  set of operations......
</portType>

<binding>
  protocol and data format specification....
</binding>

</definitions>

我想要做的是向wsdl添加服务质量(QoS)属性,因此新结构将变为如下所示:

<definitions>

<types>
  data type definitions........
</types>

<message>
  definition of the data being communicated....
</message>

<portType>
  set of operations......
</portType>

<binding>
  protocol and data format specification....
</binding>
<QoS>
Qos criteria.....
</QoS>
</definitions>

例如,此属性将添加到wsdl:

  <Reliability Qualification="threshold-best-effort" Offered="true">
        <TimeToFailure value= 500000000 unit="sec" source="measured"
        type=”mean” direction=”increasing />
 </Reliability>

结果应如下所示,<Reliability>属性将插入<service>

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://sample" xmlns:qwsdl="http://example.com/stockquote/schemas"  xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://sample" xmlns:intf="http://sample" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:import namespace = "http://localhost:8080/WSDLExtention/wsdl/stockquote.xsd" location="http://localhost:8080/WSDLExtention/wsdl/stockquote.xsd"/>
 <wsdl:types>
  <schema elementFormDefault="qualified" targetNamespace="http://sample" xmlns="http://www.w3.org/2001/XMLSchema">
   <element name="myCalculation">
    <complexType>
     <sequence>
      <element name="decimal" type="xsd:string"/>
     </sequence>
    </complexType>
   </element>
   <element name="myCalculationResponse">
    <complexType>
     <sequence>
      <element name="myCalculationReturn" type="xsd:string"/>
     </sequence>
    </complexType>
   </element>

  </schema>
 </wsdl:types>

   <wsdl:message name="myCalculationResponse">

      <wsdl:part element="impl:myCalculationResponse" name="parameters">

      </wsdl:part>

   </wsdl:message>

   <wsdl:message name="myCalculationRequest">

      <wsdl:part element="impl:myCalculation" name="parameters">

      </wsdl:part>

   </wsdl:message>

   <wsdl:portType name="Calculation">

      <wsdl:operation name="myCalculation">

         <wsdl:input message="impl:myCalculationRequest" name="myCalculationRequest">

       </wsdl:input>

         <wsdl:output message="impl:myCalculationResponse" name="myCalculationResponse">

       </wsdl:output>

      </wsdl:operation>

   </wsdl:portType>

   <wsdl:binding name="CalculationSoapBinding" type="impl:Calculation">

      <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

      <wsdl:operation name="myCalculation">

         <wsdlsoap:operation soapAction=""/>

         <wsdl:input name="myCalculationRequest">

            <wsdlsoap:body use="literal"/>

         </wsdl:input>

         <wsdl:output name="myCalculationResponse">

            <wsdlsoap:body use="literal"/>
         </wsdl:output>

      </wsdl:operation>

   </wsdl:binding>

   <wsdl:service name="CalculationService">

      <wsdl:port binding="impl:CalculationSoapBinding" name="Calculation">

         <wsdlsoap:address location="http://localhost:8080/Action1/services/Calculation"/>
      </wsdl:port>

   <Reliability Qualification="threshold-best-effort" Offered="true">
    <TimeToFailure value= 500000000 unit="sec" source="measured"
    type=”mean” direction=”increasing />
    </Reliability>
   </wsdl:service>

</wsdl:definitions

我尝试向wsdl添加新架构,但它总是失败。有可能吗?知道如何将这个新属性添加到WSDL文件中吗?

1 个答案:

答案 0 :(得分:0)

WSDL有一个标准的definition,你无法像这样自定义它。

根据您的绑定定义根据此架构。

http://www.w3.org/TR/wsdl#A4.2

您可以使用this架构(Ext

执行此操作
<element name="service" type="wsdl:serviceType"/>
   <complexType name="serviceType">
      <complexContent>
   <extension base="wsdl:documented">
   <sequence>
   <element ref="wsdl:port" minOccurs="0" maxOccurs="unbounded"/>
      <any namespace="##other" minOccurs="0"/>
  </sequence>
      <attribute name="name" type="NCName" use="required"/>
   </extension>
  </complexContent>
  </complexType>

但我从未尝试过,没有任何样本。