How to make an listing in xml

I have several types of queries that are really enumerations.

But in my code, these types of queries are an enumeration:

enum RequestType { RequestRegister, RequestUnregister, etc }; 

My current wsdl file attempt is given below. But it uses a string type. On my server, I need to extract enum / int from xml. Performing a string search looks like a bad design.

So how do I create a wsdl file so that request types are listed?

 <?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 (without control over this). But I am compiling the xml that the client uses. The server on which I control / write is written in C ++, and I use libxml to extract the "parts" of the xml file. Ideally, the element should be int or enum. Because I want, for example, to do this:

// retrieve an element from xml - in enum or int RequestType rqtype = getRequestType ();

 switch(rqtype) { case RequestMakeCall: //do whatever 

In the above case, RequestType is an enumeration. It is inefficient to retrieve a string value and then search for the associated enumeration value.

All the examples I see in the listings seem to use strings that seem odd.

+4
source share
1 answer

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> 
+3
source

All Articles