Commander
Commander
460 views

Failing to send xml in the REST driver

Hi,

I'm trying to set up a REST-driver that will send its data as xml instead of JSON and I can't get it to work. Does anyone have an example of how a proper document should look like? The only example in the documentation uses JSON.

My attempt so far looks like this. Replacing the content of the value node with some JSON text and changing the content type to application/json works fine.

<nds dtdversion="4.0" ndsversion="8.x">
<source>
<product edition="Advanced" version="4.7.1.1">DirXML</product>
<contact>NetIQ Corporation</contact>
</source>
<input>
<add cached-time="20201216105057.775Z" class-name="User" event-id="IAMIDM01#20201216105057#2#1:a1639d42-0733-409e-b221-429d63a13307" qualified-src-dn="O=IDM\OU=Users\CN=User1" src-dn="\IDM-TREE\IDM\Users\User1" src-entry-id="1130087" timestamp="0#0">
<association state="manual"></association>
<add-attr attr-name="firstName">
<value timestamp="1509383032#384" type="string">Test</value>
</add-attr>
<add-attr attr-name="email">
<value timestamp="1509383032#395" type="string">**PERSONAL INFORMATION REMOVED**</value>
</add-attr>
<add-attr attr-name="costCenter">
<value type="string">aaaa00</value>
</add-attr>
<add-attr attr-name="lastName">
<value timestamp="1509383032#386" type="string">Person</value>
</add-attr>
<add-attr attr-name="employeeNumber">
<value timestamp="1509383032#397" type="string">User01</value>
</add-attr>
<add-attr attr-name="departmentName">
<value timestamp="1509616894#70" type="string">IT</value>
</add-attr>
<add-attr attr-name="departmentCode">
<value timestamp="1509616894#74" type="string">Department</value>
</add-attr>
</add>
<driver-operation-data class-name="User" command="add">
<request>
<url-token/>
<header content-type="application/xml"/>
<value>
<userRecords>
<userRecord>
<id>prnn01</id>
<userAttribute>
<name>firstName</name>
<value>Test</value>
</userAttribute>
<userAttribute>
<name>email</name>
<value>**PERSONAL INFORMATION REMOVED**</value>
</userAttribute>
<userAttribute>
<name>costCenter</name>
<value>aaaa00</value>
</userAttribute>
<userAttribute>
<name>lastName</name>
<value>Person</value>
</userAttribute>
<userAttribute>
<name>employeeNumber</name>
<value>User01</value>
</userAttribute>
<userAttribute>
<name>departmentName</name>
<value>IT</value>
</userAttribute>
<userAttribute>
<name>departmentCode</name>
<value>Department</value>
</userAttribute>
</userRecord>
</userRecords>
</value>
</request>
</driver-operation-data>
</input>
</nds>
[12/16/20 11:52:18.625]:REST Driver ST:REST Driver: sub-execute
[12/16/20 11:52:18.625]:REST Driver ST:REST Driver: addHandler
[12/16/20 11:52:18.626]:REST Driver ST:REST Driver: addHandler: class-name == 'User'
[12/16/20 11:52:18.626]:REST Driver ST:REST Driver: Add: preparing POST to https://ourwebservice.com/webservice/
[12/16/20 11:52:18.626]:REST Driver ST:SubscriptionShim.execute() returned:
[12/16/20 11:52:18.626]:REST Driver ST:
<nds dtdversion="3.0">
<source>
<product build="20180206_0824" version="1.0.0.2">Identity Manager REST Driver</product>
<contact>NetIQ Corporation.</contact>
</source>
<output>
<status level="fatal" type="driver-status">
<description>java.lang.IllegalArgumentException: Source string may not be null</description>
<exception class-name="java.lang.IllegalArgumentException">
<message>Source string may not be null</message>
<stack-trace>java.lang.IllegalArgumentException: Source string may not be null
at org.apache.http.util.Args.notNull(Args.java:54)
at org.apache.http.entity.StringEntity.&lt;init>(StringEntity.java:67)
at org.apache.http.entity.StringEntity.&lt;init>(StringEntity.java:118)
at com.novell.nds.dirxml.driver.rest.HttpRESTAddOperation.sendHttpRequest(HttpRESTOperations.java:605)
at com.novell.nds.dirxml.driver.rest.RESTSubscriptionShim.handleDriverOperationNode(RESTSubscriptionShim.java:752)
at com.novell.nds.dirxml.driver.rest.RESTSubscriptionShim.handleCommandOperation(RESTSubscriptionShim.java:871)
at com.novell.nds.dirxml.driver.rest.RESTSubscriptionShim.addHandler(RESTSubscriptionShim.java:903)
at com.novell.nds.dirxml.driver.rest.RESTSubscriptionShim.dispatch(RESTSubscriptionShim.java:667)
at com.novell.nds.dirxml.driver.rest.RESTSubscriptionShim.execute(RESTSubscriptionShim.java:493)
at com.novell.nds.dirxml.engine.Subscriber.execute(Subscriber.java:473)
at com.novell.nds.dirxml.engine.Subscriber.execute(Subscriber.java:304)
at com.novell.nds.dirxml.engine.Subscriber$AddProcessor.process(Subscriber.java:1623)
at com.novell.nds.dirxml.engine.Subscriber$SyncProcessor.processUnassociatedSync(Subscriber.java:2041)
at com.novell.nds.dirxml.engine.Subscriber$SyncProcessor.process(Subscriber.java:1917)
at com.novell.nds.dirxml.engine.Subscriber.processEvent(Subscriber.java:1197)
at com.novell.nds.dirxml.engine.Subscriber.processEvents(Subscriber.java:1010)
at com.novell.nds.dirxml.engine.Driver.submitTransaction(Driver.java:901)
at com.novell.nds.dirxml.engine.DriverEntry.submitTransaction(DriverEntry.java:1174)
at com.novell.nds.dirxml.engine.DriverEntry.processCachedTransaction(DriverEntry.java:1058)
at com.novell.nds.dirxml.engine.DriverEntry.eventLoop(DriverEntry.java:866)
at com.novell.nds.dirxml.engine.DriverEntry.run(DriverEntry.java:640)
at java.lang.Thread.run(Thread.java:748)
</stack-trace>
</exception>

Thank you in advance! 

Regards,
Philip Sundqvist

0 Likes
7 Replies
Vice Admiral
Vice Admiral

A bit of a shot in the dark... have you tried removing spaces and new lines from your value xml?  Perhaps put quotes around it so it is treated as a string?

Micro Focus Expert
Micro Focus Expert

I'll have to ask: why don't you use the SOAP driver?

In the REST driver, you'd have to serialize your userRecords element into a text to put into the value element. But it's entirely possible that the REST shim expects a valid JSON object within the value element...

--
Norbert
0 Likes
Commander
Commander

The receiving application expects a REST request, so I don't think a SOAP driver would work. I agree that it seems like it expects a JSON object to be present in the value element.

I think I'll open an SR about this, according to the docs it should be possible.

0 Likes
Admiral
Admiral

Have you thought about using Stefaan's driver for text protocols: http://vancauwenberge.info/#txtp

With that one you should be able to do what you want, as I suspect that the Rest driver will not be able to talk XML.

 

Commander
Commander

Good idea. I was building the XML document using the append xml element token. But unfortunately sending it all as a text string made no difference, with or without quotes.

0 Likes
Micro Focus Expert
Micro Focus Expert

Did you text version look like this?

<nds dtdversion="4.0" ndsversion="8.x">
  <source>
    <product version="4.8.2.0">DirXML</product>
    <contact>NetIQ Corporation</contact>
  </source>
  <input>
    <add cached-time="20201216105057.775Z" class-name="User" event-id="IAMIDM01#20201216105057#2#1:a1639d42-0733-409e-b221-429d63a13307" qualified-src-dn="O=IDM\OU=Users\CN=User1" src-dn="\IDM-TREE\IDM\Users\User1" src-entry-id="1130087" timestamp="0#0">
      <association state="manual"/>
      <add-attr attr-name="firstName">
        <value timestamp="1509383032#384" type="string">Test</value>
      </add-attr>
      <add-attr attr-name="email">
        <value timestamp="1509383032#395" type="string">**PERSONAL INFORMATION REMOVED**</value>
      </add-attr>
      <add-attr attr-name="costCenter">
        <value type="string">aaaa00</value>
      </add-attr>
      <add-attr attr-name="lastName">
        <value timestamp="1509383032#386" type="string">Person</value>
      </add-attr>
      <add-attr attr-name="employeeNumber">
        <value timestamp="1509383032#397" type="string">User01</value>
      </add-attr>
      <add-attr attr-name="departmentName">
        <value timestamp="1509616894#70" type="string">IT</value>
      </add-attr>
      <add-attr attr-name="departmentCode">
        <value timestamp="1509616894#74" type="string">Department</value>
      </add-attr>
    </add>
    <driver-operation-data class-name="User" command="add">
      <request>
        <url-token/>
        <header content-type="application/xml"/>
        <value>&lt;userRecords>
	&lt;userRecord>
		&lt;id>prnn01&lt;/id>
		&lt;userAttribute>
			&lt;name>firstName&lt;/name>
			&lt;value>Test&lt;/value>
		&lt;/userAttribute>
		&lt;userAttribute>
			&lt;name>email&lt;/name>
			&lt;value>**PERSONAL INFORMATION REMOVED**&lt;/value>
		&lt;/userAttribute>
		&lt;userAttribute>
			&lt;name>costCenter&lt;/name>
			&lt;value>aaaa00&lt;/value>
		&lt;/userAttribute>
		&lt;userAttribute>
			&lt;name>lastName&lt;/name>
			&lt;value>Person&lt;/value>
		&lt;/userAttribute>
		&lt;userAttribute>
			&lt;name>employeeNumber&lt;/name>
			&lt;value>User01&lt;/value>
		&lt;/userAttribute>
		&lt;userAttribute>
			&lt;name>departmentName&lt;/name>
			&lt;value>IT&lt;/value>
		&lt;/userAttribute>
		&lt;userAttribute>
			&lt;name>departmentCode&lt;/name>
			&lt;value>Department&lt;/value>
		&lt;/userAttribute>
	&lt;/userRecord>
&lt;/userRecords></value>
      </request>
    </driver-operation-data>
  </input>
</nds>
--
Norbert
0 Likes
Knowledge Partner Knowledge Partner
Knowledge Partner

I remember sending XML using the REST driver, I believe I had to serialize the XML document in the output transformation.
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.