1. Skip to navigation
  2. Skip to content

THAT'S COOL! RPG-XML SUITE TIPS & TRICKS FOR DEVELOPERS

XML Tip - SOAP Body content that is encoded

There is a common “gotcha!” associated  with web services when working from the Microsoft .NET environment that causes  the consumption of .NET web services to be more cumbersome than necessary. We  are specifically talking about how .NET web services are frequently built in a  fashion that requires the entire <soap:Body> tag contents to be URL  encoded.  This means that the following XML:  

<tag1>somevalue</tag1>

would instead need to be encoded as such:  

&lt;tag1&gt;somevalue&lt/tag1&gt;

 As you can see there  was simply a translation done to take the less than and greater than signs and  convert them to &lt; and &gt; respectively. We can determine the  cause of why this needs to happen by looking at the WSDL created from  Microsoft's Visual Studio IDE.  
 
Figure 1 contains  a portion of a WSDL that defines an interface to a county vehicle title  inquiry web service.  The TitleInquirySoapIn WSDL message points to a XML  Schema Definition (XSD) element named tns:TitleInquiry which is defined in the  <wsdl:types> area. Here is where the heart of the problem exists.   The TitleInquiry element declaration has a child element named  xmlstring.  The important thing to note is there isn’t any more child  elements defined within.  


Figure 1
At this point the SOAP XML document would look like  the following in Figure 2.  Note that there really isn't any content  defined within element <xmlstring>.  This is because instead of  further defining the XML with the WSDL's schema, the creators of this web  service simply define it in a Microsoft Word document (a very bad practice).  Instead, all of the XML elements should have been declared in the WSDL's XSD  area.  Because of this, the SOAP spec declares that everything within  <xmlstring> needs to be URL encoded.

Figure 2

Figure 3 shows what the raw request needs to look like  in order for the Microsoft .NET web service to receive it properly.  If  the XML within <xmlstring> is not escaped you can expect to get back  messages from Microsoft's IIS like “400 Bad Request”.  This error  obviously doesn't give us much to go on, but as stated it can have something  to do with how the WSDL was written and inherently how the XML is composed and  encoded.

Figure 3

We have talked about the request and how the .NET web  service requires the <soap:Body> to be URL encoded.  Now it should  also be mentioned that the response <soap:Body> will also be encoded.   Composing the XML with &lt; and &gt; is fairly easy and your  normal RPG-XML Suite template approach can work for that.  Parsing takes  on a little more complication.  
 
Before the response XML  from the .NET web service can be parsed it must first be decoded to change the  &lt; and &gt; to < and > respectively.  This will allow the  parser to recognize these as actual XML elements instead of plain text.   Fortunately, RPG-XML Suite provides the RXS_soapDecode API to easily  translate to the correct format.  Pass RXS_soapDecode the RPG variable or  IFS file containing the XML and it will quickly go through and do the  necessary translations.  Once the translation is done you can  appropriately continue with the normal approach to parsing using RPG-XML Suite  by setting up your event handlers and calling RXS_parse.   


Create your own XML web service from RPG today.

Download The Free Trial! Go

Client Satisfaction

I would like to take this opportunity to thank you for being so helpful during our process and specifically to Aaron for all your prompt communications. Apart from the functionality of the product, you have largely sold your product to us through the support you have shown.

Mark Briggs,
Pfizer Australia

Case Study

Horizon Hobby

"processes credit authorizations real-time."More

Client Satisfaction

I followed some example code on your website and have a simple app up and running very similar to what my client needs. I just need to adapt it to their JD Edwards World Database. Your software is making me look like a hero!

Carl Galgano
EDI Consulting

Client Satisfaction

With the help of RPG-XML Suite I was able to cut my personal project time in half. RPG-XML Suite is a proven toolset that allows for easy creation of XML web services from RPG. I'd recommend it to anyone on the iSeries / System i platform because it runs natively in RPG with Apache giving it excellent performance!

Bruce 'Hoss' Collins,
AAA Cooper Transportation

Client Satisfaction

RPG-XML Suite enables us to communicate from our AS400 real-time with our credit vendors, and the implementation was quick and easy. I would recommend it to anyone.

Margaret,
Spartan Insurance

Case Study

Sunbelt rentals

"....keeping Java in their coffee cup!"More

Client Satisfaction

Aaron,
I just wanted to take a few moments and say thanks for the help with the web service. I have it working now and we are creating tickets from the XML data. Really cool stuff! Thanks!

Brad Abernathy
Sunbelt Rentals




Employment

View Current
Employment Opportunities.

Go

Our Partners

Get an overview of how to leverage a partnership with us.

Go

FAQs

See the questions everyone else is asking.

Read

Glossary of Terms

Get a better handle
on all the acronymns.

Read