Posts

Showing posts from July, 2016

MEC: Call Web Service in a cleaner way

Image
BackgroundIn the MEC mapper, calling a web service is a general scenario. There are few ways to do it. One method is build the SOAP request Payload in a string and submit via POST method. (as below code snippet) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18java.net.URL obj =new java.net.URL(iURL); java.net.HttpURLConnection con =(java.net.HttpURLConnection) obj.openConnection(); con.setRequestMethod("POST"); con.setRequestProperty("Content-Type","text/xml"); con.setRequestProperty("Accept","text/xml"); String itemStr ="<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"+"<soap:Body>"+"<GetItem xmlns=\"http://tempuri.org/\">"+"<itemNumber>KelumG</itemNumber>"+"</Ge…