Skip to Content
0

passing some fields from SOAP lookup response xml string to some fields in target structure in UDF

Feb 07 at 07:44 AM

32

avatar image
Former Member

Hi All,

In my scenario i have to call a webservice using soap look up and pass some fields from lookup response to somefields in the target structure.

I am able to get response using soap lookup as xml string but i am stuck at passing few fields from response xml to target structure using result list. Can you please guide me how to pass the fields from response xml to target structure.

AbstractTrace trace = container.getTrace();
StringBuilder response = new StringBuilder();
try {
  Channel channel = LookupService.getChannel("Comm Component","Communication Channel");
  SystemAccessor accessor = LookupService.getSystemAccessor(channel);
  /* Construct the SOAP Request Message using the InputParameters.*/     
  String SOAPxml = "input message to soap lookup";
  trace.addInfo(SOAPxml);
  InputStream inputStream = new ByteArrayInputStream(SOAPxml.getBytes());
  XmlPayload payload = LookupService.getXmlPayload(inputStream);
  Payload SOAPOutPayload = null;
   SOAPOutPayload = accessor.call(payload);
   BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(SOAPOutPayload.getContent()));
               String line = "";
        while (line != null) {
            response.append(line);
            line = bufferedReader.readLine();
trace.addInfo(response.toString());
        }
}
      
catch (Exception e){
    trace.addWarning("Error" + e);
}
  return response.toString();

Please provide your inputs.

Thanks


                
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
avatar image
Former Member Feb 12 at 07:27 PM
0

Hi All,

I had to select specific element from the UDF and take values only under that., i was able to achieve my requirement.

used below code to parse the xml from output.

NodeList list = document.getElementsByTagName("element");
		//if(list!=null)
		for (int i = 0; i < list.getLength(); i++) 
		{
			NodeList childList = list.item(i).getChildNodes();
			for (int j = 0; j < childList.getLength(); j++) 
			{
				Node childNode = childList.item(j);
				if ("TransactionId".equals(childNode.getNodeName())) 
				{
					TransactionID=childList.item(j).getTextContent();
					trace.addInfo(TransactionID);
				}
		
  }
  }
result.addValue(TransactionID);
Share
10 |10000 characters needed characters left characters exceeded
Priyanka Anagani Feb 07 at 10:09 AM
0

Hi Laxmi,

You need to parse the response XML and retrieve the values of XML fields and then map it to target. Refer below.

https://answers.sap.com/questions/222306/map-the-decompressed-field-which-returns-an-xml-to.html?childToView=222927#answer-222927

https://archive.sap.com/discussions/thread/1978579

---Priyanka

Share
10 |10000 characters needed characters left characters exceeded