I have a number of request types - which really are enums.
But in my code these request types are an enum:
enum RequestType {
RequestRegister,
RequestUnregister,
etc
};
My current attempt at a wsdl file is below. But it uses a string type. In my server I need to extract an enum/int from the xml. Doing lookups on a string seems like bad design.
So how do I form my wsdl file so that the request types are enums?
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="CubaCTI"
targetNamespace="http://www.iteloffice.com/wsdl/cubacti.wsdl"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.iteloffice.com/wsdl/cubacti.wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<message name="MonitorStartRequest">
<part name="user_name" type="xsd:string" />
<part name="password" type="xsd:string" />
<part name="dn" type="xsd:string"/>
</message>
<message name="MonitorStartResponse">
<part name="errorcode" type="xsd:short"/>
<part name="errormessage" type="xsd:string"/>
</message>
<message name="MonitorStopRequest">
<part name="user_name" type="xsd:string" />
<part name="password" type="xsd:string" />
<part name="dn" type="xsd:string"/>
</message>
<message name="MonitorStopResponse">
<part name="errorcode" type="xsd:short"/>
<part name="errormessage" type="xsd:string"/>
</message>
<message name="MakeCallRequest">
<part name="user_name" type="xsd:string" />
<part name="password" type="xsd:string" />
<part name="dn" type="xsd:string"/>
<part name="destination" type="xsd:string"/>
<part name="userdata" type="xsd:string"/>
</message>
<message name="MakeCallResponse">
<part name="errorcode" type="xsd:short"/>
<part name="errormessage" type="xsd:string"/>
</message>
<message name="ClearConnectionRequest">
<part name="user_name" type="xsd:string" />
<part name="password" type="xsd:string" />
<part name="dn" type="xsd:string"/>
<part name="destinationconnectionid" type="xsd:string"/>
</message>
<message name="ClearConnectionResponse">
<part name="errorcode" type="xsd:short"/>
<part name="errormessage" type="xsd:string"/>
</message>
<portType name="CubaCTIRequests">
<operation name="MonitorStart">
<input message="tns:MonitorStartRequest"/>
<output message="tns:MonitorStartResponse"/>
</operation>
<operation name="MonitorStop">
<input message="tns:MonitorStopRequest"/>
<output message="tns:MonitorStopResponse"/>
</operation>
<operation name="MakeCall">
<input message="tns:MakeCallRequest"/>
<output message="tns:MakeCallResponse"/>
</operation>
<operation name="ClearConnection">
<input message="tns:ClearConnectionRequest"/>
<output message="tns:ClearConnectionResponse"/>
</operation>
</portType>
<binding type="tns:CubaCTIRequests" name="cubactibinding">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="MonitorStart">
<soap:operation soapAction="MonitorStart"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="MonitorStop">
<soap:operation soapAction="MonitorStop"/>
<input>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://www.iteloffice.com/cubctirequests"
use="encoded"/>
</input>
<output>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://www.iteloffice.com/cubctirequests"
use="literal"/>
</output>
</operation>
<operation name="MakeCall">
<soap:operation soapAction="MakeCall"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="ClearConnection">
<soap:operation soapAction="ClearConnection"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="CubaCTI_Service">
<documentation>WSDL File for Cuba CTI services</documentation>
<port binding="tns:cubactibinding" name="CubaCTIRequestsBinding">
<soap:address
location="http://angusnotebook:8080"/>
</port>
</service>
</definitions>
Additional note.
I am 'forced' to use xml because the client can only send xml messages (no control over this). But I make up the xml that the client uses. The server, which I have control of/write is written in C++ and I am using libxml to extract the 'parts' of the xml file. Ideally the item would be an int or enum. Because I want to eg do this:
//extract item from xml - into an enum or int RequestType rqtype = getRequestType();
switch(rqtype) {
case RequestMakeCall:
//do whatever
In the above case RequestType is an enum. It is not efficient to extract a string value and then have to do a lookup of the related enum value.
All the examples I see of enums seem to use strings, which seems odd.
You can create your own types:
<definitions targetNamespace="http://www.iteloffice.com/wsdl/cubacti.wsdl"
xmlns:tns="Mediaresearch.SimNet.Communication"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<s:schema elementFormDefault="qualified"
targetNamespace="http://www.iteloffice.com/wsdl/cubacti.wsdl">
<s:simpleType name="OperatingSystemVersion">
<s:restriction base="s:string">
<s:enumeration value="None" />
<s:enumeration value="WinXp" />
<s:enumeration value="WinVista" />
<s:enumeration value="Win7" />
</s:restriction>
</s:simpleType>
</s:schema>
</types>
<message name="OperatingSystemVersion">
<part name="user_name" type="tns:OperatingSystemVersion" />
</message>
</definitions>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With