dlukyanov edited this page Sep 24, 2015 · 9 revisions

WSDL is a key technology for SOA, and yet creating and editing these files is about as much fun as straightening all the noodles in a bowl of spaghetti with a pair of tweezers.

Relax-ws provides a simple, compact syntax for generating WSDL's. It does this by extending RelaxNG Compact syntax with support for services, ports, operations, and messages.

Some teams use code-driven development, whereby they write Java or C# interfaces and let their framework generate the WSDL. This is fast for development, but can easily result in platform-specific features sneaking in, which renders the interface unusable for cross-platform clients.

An even greater problem with code-driven development is the evaporation of interface metadata that occurs during translation into WSDL. Comments are not converted, nor are any but the most simple type declarations (ie, the length of an xsd:string field, or the number of digits in a decimal field, etc). These are important attributes for the consumer of the service to know about.

The opposite approach is WSDL-driven development. The programmer begins with a WSDL file, and as part of the build generates the service interface that is then implemented by one or more classes. The challenge here lies in creating the WSDL!

Relax-WS aims to provide a simple, programmer-friendly syntax, without losing any of the metadata. Read more in the wiki.

Usefull documentation about relaxng compact syntax:

relax-ws/doc/rnc.pdf

Here's a quick example:

#
# This is "hello world" in relax-ws.
#
service Hello {

    interface {
        operation SayHello {
            in {
                element name {xsd:string}
            }

            out {
                element message {xsd:string}            
            }

        }

    }
}

And here is the generated WSDL file:

<?xml version="1.0"?>
<definitions name="Hello"
             targetNamespace="http://code.google.com/p/relax-ws/samples/hello"
             xmlns:tns="http://code.google.com/p/relax-ws/samples/hello"
             xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
             xmlns="http://schemas.xmlsoap.org/wsdl/">

  <types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" 
targetNamespace="http://code.google.com/p/relax-ws/samples/hello" 
xmlns:hello="http://code.google.com/p/relax-ws/samples/hello">
  <xs:element name="SayHelloRequest">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="hello:name"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="name" type="xs:string"/>
  <xs:element name="SayHelloResponse">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="hello:message"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="message" type="xs:string"/>
</xs:schema>
  </types>

  <message name="SayHelloInput">
    <part name="body" element="tns:SayHelloRequest"/>
  </message>
  <message name="SayHelloOutput">
    <part name="body" element="tns:SayHelloResponse"/>
  </message>

  <portType name="HelloPort">
    <operation name="SayHello">
      <input message="tns:SayHelloInput"/>
      <output message="tns:SayHelloOutput"/>
    </operation>
  </portType>

  <binding name="HelloPortSoapBinding" type="tns:HelloPort">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="SayHello">
      <soap:operation soapAction="http://code.google.com/p/relax-ws/samples/hello/HelloPort#SayHello"/>
      <input>
        <soap:body use="literal"/>
      </input>
      <output>
        <soap:body use="literal"/>
      </output>
    </operation>
  </binding>

  <service name="HelloHelloPortService">
    <port name="HelloPort" binding="tns:HelloPortSoapBinding">
      <soap:address location="http://example.com/Hello"/>
    </port>
  </service>
</definitions>
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.