How to change order of elements in WSDL

11
Hi Everyone, This is more of knowledge sharing then a question. It might be most of you already know this but when I searched in forum on how to change order of elements in WSDL, I did not find a good solution to it so I thought to share this issue and its solution with Mendix community. Issue - Recently I had an issue where we published a web service that was consumed by SAP to send contact details into our Mendix app. The developer of SAP confirmed that he can successfully call the published web service by using SOAPUI and when he deployed his changes to test/ accp he started getting errors and web service failed to connect. After investigation we found this was due to the order of elements that was defined in the WSDL of published web service. I know the elements order doesn't matter in most of the cases but in this case the elements order was hard-coded by him in SAP PI. It was a small change on his side but was too late for him to change anything due to SAP development freeze. We were left with two options, wait for a month until the dev freeze is completed or change the order of elements in our WSDL. Solution - I started investigating if we can change the order of elements in WSDL and thanks to Simon Black we found out the elements order in WSDL is generated based on which entity / attribute / association is created first. For example in our case we had two entities ContactFeed and ContactFeedData associated one to many. As shown in the WSDL below after element sysId, element date is generated next in the WSDL and ContactFeedData is next to date. We want to change the order of element ContactFeedData and its attributes to be generated after sysId and date element should be below ContactFeedData. <xsd:element name="ContactFeed"> <xsd:complexType> <xsd:sequence> <xsd:element name="sysId" type="xsd:string" /> <xsd:element name="Date" type="xsd:string" /> ==> This element should go below ContactFeedData elements. <xsd:element name="ContactFeedData_ContactFeed"> <xsd:complexType> <xsd:sequence> <xsd:element name="ContactFeedData" minOccurs="0" maxOccurs="unbounded"> <xsd:complexType> <xsd:sequence> <xsd:element name="Id"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:maxLength value="20" /> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="FName"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:maxLength value="40" /> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="SName"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:maxLength value="40" /> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="JobTitle"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:maxLength value="40" /> </xsd:restriction> </xsd:simpleType> </xsd:element> etc etc ......... </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> ---- Element date must be here ---- <xsd:element name="Time" type="xsd:string" /> <xsd:element name="NoOfContacts" type="xsd:long" /> </xsd:sequence> </xsd:complexType> </xsd:element> To change the order of elements in WSDL, I had to delete web serivce operation, both the entities and its association. As I mentioned earlier WSDL is generated based on what is created first. Then I started creating what I required in the WSDL to be first. Hence first I created entity ContactFeed and then one attribute sysId. Next created ContactFeedData entity and its association and then attributes of ContactFeedData. Lastly after that I created remaining attributes of ContactFeed entity which are date, time, NoOfContacts. Once everything is created, published the microflow as web service again which generated the WSDL with the order of elements that I wanted as shown below. <xsd:element name="ContactFeed"> <xsd:complexType> <xsd:sequence> <xsd:element name="sysId" type="xsd:string" /> <xsd:element name="ContactFeedData_ContactFeed"> <xsd:complexType> <xsd:sequence> <xsd:element name="ContactFeedData" minOccurs="0" maxOccurs="unbounded"> <xsd:complexType> <xsd:sequence> <xsd:element name="Id"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:maxLength value="20" /> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="FName"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:maxLength value="40" /> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="SName"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:maxLength value="40" /> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="JobTitle"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:maxLength value="40" /> </xsd:restriction> </xsd:simpleType> </xsd:element> etc etc ......... </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="Date" type="xsd:string" /> ==> Date element is now moved below ContactFeedData <xsd:element name="Time" type="xsd:string" /> <xsd:element name="NoOfContacts" type="xsd:long" /> </xsd:sequence> </xsd:complexType> </xsd:element> Apologies for long message, there might be other solutions to this that I don't know but just thought to share the issue which I faced and the solution to it. It will be nice feature to have if Mendix allows us to change the order of elements in the web service operation something like having a move up or down button. Hope this helps the community!
asked
0 answers