Skip to Content
0

error while reading url value from rest sender adapter

Nov 08, 2017 at 09:12 AM

111

avatar image
Former Member

Hi All,

We are developing the interface where need to read the value from the URL by using rest sender adapter but facing issue in consuming the value .

Error:

cannot create target element. Not able to pass the value to the attribute

Adapter config:

end point: /rest/sapecc/v1/frankolicense/licensenumber

Pattern: /{licensenumber}

dynamic attribute: rest service/URL pattern/licensenumber

rest operation: http operation

general: JSON/http content type header

Mapping:

namespace(http://sap.com/xi/XI/System/REST) first input to getasma (UDF), Second input licensenumber.

Note: License number will be passed to the URL

Example:http://Host:Port/RESTAdapter/rest/sapecc/v1/frako/licensenumber/520501

I have gone through lot of posts related to the same requirement but helpless.

Thanks & Regards,

kiran.

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

2 Answers

Muniyappan Marasamy Nov 08, 2017 at 10:03 AM
0

if you dont mind could you pleas share you channel configuration(dynamic conifig) and UDF dynamic config code?

Show 27 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Muni,

Channel config:

end point: /rest/sapecc/v1/frankolicense/licensenumber

Pattern: /{licno}

dynamic attribute: Custom/URL pattern/licno

rest operation: http operation

general: JSON/http content type header

Sender Rest Adapter Error: Catching exception calling messaging system

Thanks & Regards,

Ravi.

0

can you paste your udf here please?

0
Former Member
Muniyappan Marasamy

Hi Muni,

UDF:

public String getASMA(String namespace, String attribute, Container container) throws StreamTransformationException{

Map<String, Object> all = container.getInputHeader().getAll(); DynamicConfiguration dynConf = (DynamicConfiguration)all.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION); DynamicConfigurationKey key = DynamicConfigurationKey.create( namespace, attribute); String value = dynConf.get(key); return value;

Thanks & Regards,

Ravi.

0

Hmm. I see why it is not working.

try this in the udf

DynamicConfiguration dynConf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
 DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/REST", "licno");
 String value = dynConf.get(key);
return value;
0
Former Member
Muniyappan Marasamy

Hi Muni,

I updated the UDF as you mentioned above but still facing the issue.

Error:

<html><head><title>Error</title></head> <body><h1>Error</h1><pre> Error while sending message to module processor: Sender Channel 'CC_Sender_REST_FrankoLicenseAddress' (ID: 8e4d282fd60c3132ba4b61be01cf2660): Catching exception calling messaging system: Mapping failed in runtimeRuntime Exception when executing application mapping program com/sap/xi/tf/_MM_FrankoLicenseAddress_REQ_; Details: com.sap.aii.mappingtool.tf7.IllegalInstanceException; Cannot create target element /ns1:ZEK_FRA_ANVGR/IP_LICNR. Values missing in queue context. Target XSD requires a value for this element, but the target-field mapping does not create one. Check whether the XML instance is valid for the source XSD, and whether the target-field mapping fulfils the requirement of the target XSD: Runtime Exception when executing application mapping program com/sap/xi/tf/_MM_FrankoLicenseAddress_REQ_; Details: com.sap.aii.mappingtool.tf7.IllegalInstanceException; Cannot create target element /ns1:ZEK_FRA_ANVGR/IP_LICNR. Values missing in queue context. Target XSD requires a value for this element, but the target-field mapping does not create one. Check whether the XML instance is valid for the source XSD, and whether the target-field mapping fulfils the requirement of the target XSD: Cannot create target element /ns1:ZEK_FRA_ANVGR/IP_LICNR. Values missing in queue context. Target XSD requires a value for this element, but the target-field mapping does not create one. Check whether the XML instance is valid for the source XSD, and whether the target-field mapping fulfils the requirement of the target XSD </pre></body></html>

Thanks & Regards,

Ravi.

0

Hi Kiran!

Did you check that required DC attribute was put in Message Header section?

Regards, Evgeniy.

0
Former Member
Evgeniy Kolmakov

Hi Evgeniy,

Yes, we maintained the attribute in message header section under xi dynamic attribute as licno, Sorry correct me if i a wrong.

Thanks & Regards,

Ravi.

0
Former Member
Former Member
mapping.jpg (22.8 kB)
0

And why do you set "id" as parameter name in your UDF parameter when your DC parameter's actual name is "licno"?

Regards, Evgeniy.

0
Former Member
Evgeniy Kolmakov

UDF:

UDF:

DynamicConfiguration dynConf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION); DynamicConfigurationKey key = DynamicConfigurationKey.create(http://sap.com/xi/XI/System/REST, licno); String value = dynConf.get(key); return value;

0
Former Member
Evgeniy Kolmakov

Hi evgenity,

I am using rest id in the channel config, So used id in the mapping.

Regards,

Ravi.

0
Former Member
Evgeniy Kolmakov
channel-para1.jpg (40.0 kB)
0
Former Member
Former Member
channel-para2.jpg (26.9 kB)
0
Former Member
Former Member
channel-para3.jpg (30.1 kB)
0
Former Member
Former Member
channel-para4.jpg (20.9 kB)
0
Former Member
Former Member
channel-para5.jpg (40.8 kB)
0

I hope, that wont affect as udf is using hard coded value while creating key.

0

can you share the screen shot of communication channel which shows the dynamic configuration part?

also check in message monitoring what values are coming in the dynamic configuration.

0
Former Member
Muniyappan Marasamy
mm-payload.jpg (29.0 kB)
0
Former Member
Former Member
dynamic-confic.jpg (121.9 kB)
0

Before going into monitoring, let us fix in configuration part.

can you change your DC attribute to custom attribute? check screenshots in below thread.

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

1
Former Member
Muniyappan Marasamy

Hi Muni,

I changed according to the url shared but still facing the same issue.

Mapping Issue:

<html><head><title>Error</title></head> <body><h1>Error</h1><pre> Error while sending message to module processor: Sender Channel 'CC_Sender_REST_FrankoLicenseAddress' (ID: 8e4d282fd60c3132ba4b61be01cf2660): Catching exception calling messaging system: Mapping failed in runtimeRuntime Exception when executing application mapping program com/sap/xi/tf/_MM_FrankoLicenseAddress_REQ_; Details: com.sap.aii.mappingtool.tf7.IllegalInstanceException; Cannot create target element /ns1:ZEK_FRA_ANVGR/IP_LICNR. Values missing in queue context. Target XSD requires a value for this element, but the target-field mapping does not create one. Check whether the XML instance is valid for the source XSD, and whether the target-field mapping fulfils the requirement of the target XSD: Runtime Exception when executing application mapping program com/sap/xi/tf/_MM_FrankoLicenseAddress_REQ_; Details: com.sap.aii.mappingtool.tf7.IllegalInstanceException; Cannot create target element /ns1:ZEK_FRA_ANVGR/IP_LICNR. Values missing in queue context. Target XSD requires a value for this element, but the target-field mapping does not create one. Check whether the XML instance is valid for the source XSD, and whether the target-field mapping fulfils the requirement of the target XSD: Cannot create target element /ns1:ZEK_FRA_ANVGR/IP_LICNR. Values missing in queue context. Target XSD requires a value for this element, but the target-field mapping does not create one. Check whether the XML instance is valid for the source XSD, and whether the target-field mapping fulfils the requirement of the target XSD </pre></body></html>

0
Former Member
Muniyappan Marasamy

Hi All,

The issue is resolved for one attribute but now i need to pass multiple attributes in the URl. Would you please help me is there any way or procedure to implement this. XML shared below.

<?xml version="1.0" encoding="UTF-8"?> <price_request> <header> <customer_country>SE</customer_country> <customer_number>0020001234</customer_number> <price_date>20170317</price_date> <sender_country>SE</sender_country> <sender_post_code>11218</sender_post_code> <receiver_country>SE</receiver_country> <receiver_post_code>16863</receiver_post_code> </header> <item> <main> <quantity>1</quantity> <service_code>1001026</service_code> <item_type>pallet_eur</item_type> <weight>76.2</weight> <volume>1.92</volume> <length>1.200</length> <width>0.800</width> <height>2.000</height> <distance>556</distance> <customer_weight>7.62</customer_weight> <customer_volume>0.308</customer_volume> <customer_volume_uom>cubic_metres</customer_volume_uom> <supplementary> <quantity>1</quantity> <service_code>1001091</service_code> </supplementary> <supplementary> <quantity>1</quantity> <service_code>2006850</service_code> <insured_value currency="SEK">50000</insured_value> </supplementary> </main> </item> </price_request>

We have Header and line items in the xml.

Regards,

Ravi.

0

Buddy, you have to first close this thread and open new one. we can not discuss all issues in one thread, it will mislead others who have similar issue.

0
Former Member
Muniyappan Marasamy

Hi Muni,

Sorry , Closing the thread.

New thread: 353877

Thanks & Regards,

Ravi.

0

in your mapping in the root node, pass constant to ZEK_FRA_ANVGR.

dont map from source to target. you can pass any constant value blank, 1, etc

Also check as in the monitoring what values you are getting?

value1.png (2.8 kB)
value.png (34.7 kB)
0
Former Member

Thanks All now it is working. the issue is with UDF

0
Priyanka Anagani Nov 08, 2017 at 10:09 AM
0

Hi Kiran,

If I understand your issue correctly, you've problem in configuring the REST endpoint in channel and retrieving it in mapping. Try with below approach.

http://Host:Port/RESTAdapter/rest/sapecc/v1/frako/licensenumber/520501

Channel Selection Tab
SpecifyEndpoint-->rest
RestResources Tab
URL Pattern-->/sapecc/v1/frako/licensenumber/{licNo}
XI dynamic Attribute
Dynamic Attribute-->custom Attribute
CustomAttributeName-->licNo
ValueSource-->URL Pattern element
Pattern Element-->licNo

After receiving the message, verify the dynamic attributes of the message and see if you are getting the URL correctly or not by checking the attribute "path" of http://sap.com/xi/XI/System/REST . Then, in message mapping write a UDF to read this path and map it as required.

---Priyanka

Show 3 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Priyanka,

I had done the changes as mentioned but facing the below issue.

Error while sending message to module processor: Sender Channel 'CC_Sender_REST_FrankoLicenseAddress' (ID: 8e4d282fd60c3132ba4b61be01cf2660): Catching exception calling messaging system: Mapping failed in runtimeRuntime Exception when executing application mapping program com/sap/xi/tf/_MM_FrankoLicenseAddress_REQ_; Details: com.sap.aii.mappingtool.tf7.IllegalInstanceException; Cannot create target element /ns1:ZEK_FRA_ANVGR/IP_LICNR. Values missing in queue context. Target XSD requires a value for this element, but the target-field mapping does not create one. Check whether the XML instance is valid for the source XSD, and whether the target-field mapping fulfils the requirement of the target XSD: Runtime Exception when executing application mapping program com/sap/xi/tf/_MM_FrankoLicenseAddress_REQ_; Details: com.sap.aii.mappingtool.tf7.IllegalInstanceException; Cannot create target element /ns1:ZEK_FRA_ANVGR/IP_LICNR. Values missing in queue context. Target XSD requires a value for this element, but the target-field mapping does not create one. Check whether the XML instance is valid for the source XSD, and whether the target-field mapping fulfils the requirement of the target XSD: Cannot create target element /ns1:ZEK_FRA_ANVGR/IP_LICNR. Values missing in queue context. Target XSD requires a value for this element, but the target-field mapping does not create one. Check whether the XML instance is valid for the source XSD, and whether the target-field mapping fulfils the requirement of the target XSD.

Thanks & Regards,

Ravi.

0

Can you share the mapping you've done for "/ns1:ZEK_FRA_ANVGR/IP_LICNR" so that I can suggest further. Also, share screenshot of the Message Dynamic Attributes.

0
Former Member
Priyanka Anagani

Hi Priyanka,

http://sap.com/xi/XI/System/REST first input and id second input mapped with the UDF to Licensenumber(Target element)

Thanks & Regards,

Ravi.

0