Understanding the documents of a SOAP web service

Asked

Viewed 930 times

7

I am working with a system that offers integration through web service, more precisely SOAP.

He provides me with some Urls, which, from what I understand, provide access, describe and document the entire system.

Are they:

The documentation shows that the WSDL file can be imported directly into the Visual Studio solution, which, once again, from what I understand, generates several classes that interface with the service.

I would like to know if it is possible to use these three Urls (and only them) to understand the service and use it in the programme, without resorting to other external documents.

And, if it is, how to translate the elements contained in these XML’s into C methods#.

Excerpts from the WSDL:

<wsdl:message name="GetReservationsRequest">
    <wsdl:part name="body" element="types:GetReservations">
    </wsdl:part>
    <wsdl:part name="credentialsHeader" element="types:UserCredentials">
    </wsdl:part>
</wsdl:message>


<wsdl:message name="CreateSubclipRequest">
    <wsdl:part name="body" element="types:CreateSubclip">
    </wsdl:part>
    <wsdl:part name="credentialsHeader" element="types:UserCredentials">
    </wsdl:part>
</wsdl:message>


<wsdl:message name="GetCustomUserAttributesResponse">
    <wsdl:part name="body" element="types:GetCustomUserAttributesResponse">
    </wsdl:part>
</wsdl:message>

<wsdl:portType name="AssetsPortType">
    <wsdl:operation name="AddReservation">
        <wsdl:documentation> Adds a reservation </wsdl:documentation>
        <wsdl:input message="tns:AddReservationRequest"> </wsdl:input>
        <wsdl:output message="tns:AddReservationResponse"> </wsdl:output>
        <wsdl:fault name="AssetsFault" message="tns:AssetsFault"> </wsdl:fault>
    </wsdl:operation>

    <wsdl:operation name="AddFileMobs">
        <wsdl:documentation> Adds one or more file </wsdl:documentation>
        <wsdl:input message="tns:AddFileMobsRequest"> </wsdl:input>
        <wsdl:output message="tns:AddFileMobsResponse"> </wsdl:output>
        <wsdl:fault name="AssetsFault" message="tns:AssetsFault"> </wsdl:fault>
    </wsdl:operation>


    <wsdl:operation name="CreateFolder">
        <wsdl:documentation> Creates a new folder </wsdl:documentation>
        <wsdl:input message="tns:CreateFolderRequest"> </wsdl:input>
        <wsdl:output message="tns:CreateFolderResponse"> </wsdl:output>
        <wsdl:fault name="AssetsFault" message="tns:AssetsFault"> </wsdl:fault>
    </wsdl:operation>


    <wsdl:operation name="Search">
        <wsdl:documentation> Search for assets </wsdl:documentation>
        <wsdl:input message="tns:SearchRequest"> </wsdl:input>
        <wsdl:output message="tns:SearchResponse"> </wsdl:output>
        <wsdl:fault name="AssetsFault" message="tns:AssetsFault"> </wsdl:fault>
    </wsdl:operation>

<wsdl:operation name="AddReservation">
    <soap:operation soapAction=""/>
    <wsdl:input>
        <soap:header message="tns:AddReservationRequest" use="literal"
          part="credentialsHeader"> </soap:header>
        <soap:body use="literal" parts="body"/>
    </wsdl:input>
    <wsdl:output>
        <soap:body use="literal"/>
    </wsdl:output>
    <wsdl:fault name="AssetsFault">
        <soap:fault name="AssetsFault" use="literal"/>
    </wsdl:fault>
</wsdl:operation>


<wsdl:operation name="AddFileMobs">
    <soap:operation soapAction=""/>
    <wsdl:input>
        <soap:header message="tns:AddFileMobsRequest" use="literal"
          part="credentialsHeader"> </soap:header>
        <soap:body use="literal" parts="body"/>
    </wsdl:input>
    <wsdl:output>
        <soap:body use="literal"/>
    </wsdl:output>
    <wsdl:fault name="AssetsFault">
        <soap:fault name="AssetsFault" use="literal"/>
    </wsdl:fault>
</wsdl:operation>

Excerpts from assets.xsd:

<xsd:element type="tns:AddReservationType" name="AddReservation"/>
<xsd:complexType name="AddReservationType">
    <xsd:annotation>
        <xsd:documentation> Parameters for the AddReservation operation.
        </xsd:documentation>
    </xsd:annotation>
    <xsd:sequence>
        <xsd:element type="tns:URIListType" name="FolderURIs"/>
        <xsd:element type="xsd:int" name="TimeToExpireInSeconds"/>
        <xsd:element type="tns:ExtensionType" name="Extension" minOccurs="0"/>
        <xsd:any minOccurs="0" processContents="lax" namespace="##other"
          maxOccurs="unbounded"/>
    </xsd:sequence>
    <xsd:anyAttribute processContents="lax"/>
</xsd:complexType>

<xsd:element type="tns:AddReservationResponseType" name="AddReservationResponse"/>
<xsd:complexType name="AddReservationResponseType">
    <xsd:annotation>
        <xsd:documentation> The response from the AddReservation operation.
        </xsd:documentation>
    </xsd:annotation>
    <xsd:sequence>
        <xsd:element type="tns:ErrorListType" name="Errors" minOccurs="0"/>
        <xsd:element type="tns:ExtensionType" name="Extension" minOccurs="0"/>
        <xsd:any minOccurs="0" processContents="lax" namespace="##other"
          maxOccurs="unbounded"/>
    </xsd:sequence>
    <xsd:anyAttribute processContents="lax"/>
</xsd:complexType>

Excerpt from common.xsd:

<xsd:complexType name="AssetDescriptionType">
    <xsd:annotation>
        <xsd:documentation> A pairing of an URI representing an
          asset along with a set of attributes describing it.
        </xsd:documentation>
    </xsd:annotation>

    <xsd:sequence>
        <xsd:element name="URI" type="xsd:string"/>
        <xsd:element name="Attributes" type="tns:AttributeListType"/>
        <xsd:element name="Extension" type="tns:ExtensionType" minOccurs="0"/>
        <xsd:any minOccurs="0" maxOccurs="unbounded" processContents="lax"
          namespace="##other"/>
    </xsd:sequence>
    <xsd:anyAttribute processContents="lax"/>
</xsd:complexType>


What was generated when importing WSDL to Visual Studio:

Print da Tela do Visual Studio

2 answers

3


The translation of the WSDL takes place as follows:

  • Tags <wsdl:operation> are translated as methods that can be called. They usually have two components: <wsdl:input> and <wsdl:output>, which state the input and output data structures which, in turn, are Tags of the type <wsdl:message>;
  • Tags <wsdl:message> are translated as the body of methods that can be called, and which, in turn, are composed of <wsdl:element>;
  • Tags <wsdl:element> are translated as datasets, which can be the tags <wsdl:complexType> or <wsdl:sequence>;
  • Tags <wsdl:complexType> are translated as complex input or return objects, formed by type tags <wsdl:sequence>;
  • Tags <wsdl:sequence> are translated as arguments, which can be input or return parameters. Usually a <wsdl:complexType> contains a <wsdl:sequence>;

That’s the summary of that here.

I’ll take an example from assets.xsd: AddReservation. It is a method. It is expressed here:

<wsdl:operation name="AddReservation">

I mean, he could be called that:

new InterplayWSDemo().AddReservation(/* Coloque os parâmetros aqui */);

The description of what he accepts as arguments is here, but Intellisense does this job for you.

<xsd:element type="tns:AddReservationType" name="AddReservation"/>

That is to say, AddReservation is the body of a method accepted as a parameter AddReservationType, which is complex and has some parameters:

<xsd:complexType name="AddReservationType">
    <xsd:annotation>
        <xsd:documentation> Parameters for the AddReservation operation.
        </xsd:documentation>
    </xsd:annotation>
    <xsd:sequence>
        <xsd:element type="tns:URIListType" name="FolderURIs"/>
        <xsd:element type="xsd:int" name="TimeToExpireInSeconds"/>
        <xsd:element type="tns:ExtensionType" name="Extension" minOccurs="0"/>
        <xsd:any minOccurs="0" processContents="lax" namespace="##other"
          maxOccurs="unbounded"/>
    </xsd:sequence>
    <xsd:anyAttribute processContents="lax"/>
</xsd:complexType>

Similarly, you can bring Web Service information like this (example):

var pesquisa = new InterplayWSDemo().Search(/* Parâmetros de pesquisa conforme SearchRequest */);

0

in your solution, in References, right click, follow Add Web Reference... , informs the address: "http://localhost/services/Assets? wsdl" (localhost) the service is on your local computer ? check the address. After adding the web reference, the webservice class will be generated with its properties and methods, as well as other classes of the object types that are specified in wsdl

Browser other questions tagged

You are not signed in. Login or sign up in order to post.