on 07-29-2014 2:44 PM
Hello Experts,
I' have a senario where I need to get a session ID in order to handle a series of web service request. Therefore I have written a UDF in the mapping where the first method (as login message) where I get a login key as payload and the session-id in the response header. This session Id then needs to be set before several other calls within the same udf are made to the webservice. We are not able to use the Axis-adapter and therefore have to use the normal SOAP-adapter.
My question now is, is there any way to access the header of the first response message? I need to read the returned session-id and then write it to the other requests. Any idea?
regards
Christian
Hi Christian,
Can you show us your UDF? Maybe this blog can help:
Simple Way to Get HTTP Response Header in Java • Crunchify
Regards,
Mark
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mark,
for sure I can post the UDF. This UDF that I have written is a generic UDF that I call from several other UDF's where ever I need to create a lookup:
AbstractTrace trace = container.getTrace();
String returnValue = "";
try {
Channel channel = LookupService.getChannel(party,communicationComponent, communicationChannel);
SystemAccessor accessor = LookupService.getSystemAccessor(channel);
InputStream inputStream = new ByteArrayInputStream(requestXMLString.getBytes());
XmlPayload payload = LookupService.getXmlPayload(inputStream);
Payload SOAPOutPayload = null;
/*The SOAP call is made here and the response obtained is in the SOAPOutPayload.*/
SOAPOutPayload = accessor.call(payload);
/* Parsing the Returnvalue */
InputStream inp = SOAPOutPayload.getContent();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
/* Build DOM Structure for Input XML */
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(inp);
/* Set the XML-Tag for the Response */
NodeList list = document.getElementsByTagName(requestXMLValueTag);
Node node = list.item(0);
if (node != null)
{
node = node.getFirstChild();
if (node != null)
{
returnValue = node.getNodeValue();
}
}
} catch (Exception e)
{
trace.addWarning("Error" + e);
}
return returnValue;
So within this function I need to access the set-cookie and then set it accordingly. If have you have any suggestions I'm very happy to hear about it.
I don't think that I can use your link that you posted as I don't have a URLConnection-Object
Can you show us your UDF? Maybe this blog can help:
regards
Christian
Hi Christian,
I think dynamic configuration will not work for lookups. If they did, all you have to do is to check variable transport binding and then enter the name of the header e.g in a SOAP UI test:
In sender/receiver cc, check variable transport binding and place the name (ASMA should also be checked).
And in moni:
XHeaderName1 value can be obtained using Dynamic Config for UDF.
You need to use a UDF similar to the link I posted above.
And here it is in test tab:
PS: I am using an HTTP Proxy. If you are not using a proxy, just use
URLConnection conn = url.openConnection();
Hope this helps,
Mark
Thanks for the tip. But I can't use code example as I don't use the Connection-Object. I use the Accessor-Object for the call:
/*The SOAP call is made here and the response obtained is in the SOAPOutPayload.*/
SOAPOutPayload = accessor.call(payload);
How can I access the UDF within the accessor-Object?
Regards
Christian
Hi Christain,
Try SOAP call like this and get the header info from the response.
How to do a SOAP Web Service call from Java class? - Stack Overflow
Regards,
Rajakumar
Hi Christian,
Here is a POC that connects to this webservice StockQuote Web Service using SOAP 1.1 specifications:
For this to work, you need to import com.sap.aii.utilxi.core.io.IOUtil (you can find it in your local java directory) as an imported archive and refer it
to archives used.
The response HTTP Headers are on the left side, the SOAP Output is on the left.
Regards,
Mark
Hi Mark,
that looks really great! I've got one little problem:
I can't find the required jar: com.sap.aii.utilxi.core.io.IOUtil
I can only find these jar-files on our pi-system under /j2ee/cluster/bin/ext/com.sap.xi.util.misc/lib
Where can I find the jar-file that you have mentioned?
Regards
Christian
Hi Christian,
Can you share the UDF, how you have taken the session-id from the response header. I have similar requirement.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.