redsand007
Contributor
Contributor

vRO XML Body Format

I'm having trouble with the application/xml body format that I am trying to pass into a vRO PUT REST operation. Can anyone help determine the correct format or see what the problem is with the syntax/format:

var bodyXml = new XML(
<rs:model-request 
xsi:schemaLocation="http://www.ca.com/spectrum/restful/schema/request ../../../xsd/Request.xsd">
<rs:target-models>
<rs:models-search>
<rs:search-criteria 
<filtered-models>
<equals-ignore-case>
<attribute id="0x1006e"> <!-- This attribute stores the name of the Model -->
<value>satlrccvh501.delta.rl.delta.com</value> <!-- name to match -->
</attribute>
</equals-ignore-case>
</filtered-models>
</rs:search-criteria>
</rs:models-search>
</rs:target-models>
</rs:model-request>
)

var bodyXml = new XML(

<rs:model-request 

xmlns:rs="http://www.ca.com/spectrum/restful/schema/request"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://www.ca.com/spectrum/restful/schema/request ../../../xsd/Request.xsd">

<rs:target-models>

<rs:models-search>

<rs:search-criteria 

xmlns="http://www.ca.com/spectrum/restful/schema/filter">

<filtered-models>

<equals-ignore-case>

<attribute id="0x1006e"> <!-- This attribute stores the name of the Model -->

<value>server-name.local.com</value> <!-- name to match -->

</attribute>

</equals-ignore-case>

</filtered-models>

</rs:search-criteria>

</rs:models-search>

</rs:target-models>

</rs:model-request>

)

0 Kudos
9 Replies
iiliev
VMware Employee
VMware Employee

What is the error you are receiving?

This looks like a well-formed XML, but whether it is valid or not is determined by the service you are trying to call.

0 Kudos
redsand007
Contributor
Contributor

I am getting a 500 error.  Exact message below:

HTTP Status 500 - org.apache.cxf.interceptor.Fault: argument type mismatch while invoking public javax.xml.bind.JAXBElement

The XML is working correctly via Postman, however, as has been the case in the past when trying to run in vRO, there seems to be changes that need to be made in order to get it to work correctly..just not sure where with this one.

0 Kudos
iiliev
VMware Employee
VMware Employee

Error 500 means there is some exception on server side. Does the service you are trying to call have some logs that can provide more insights on the exception?

What version of vRO and which build number of REST plug-in do you have installed? If possible, could you try to update to the latest version of the REST plug-in (eg. the one available at https://communities.vmware.com/docs/DOC-38659) and check if the error is still there?

Are you invoking the REST operation using the stock workflows like 'Invoke a REST operation'? I think these workflows dump helpful information about the invocation, like the passed headers and content body; could you copy/paste these from the logs to see how the actual values look like before invocation?

0 Kudos
tschoergez
Leadership
Leadership

If you pass the XML content through different elements in the workflow via an attribute, make sure to do a

attributeName = bodyXml.toString();

If I remember correctly, javascript variables of type XML don't pass well over to an attribute and the next workflow element.

Also see here: Process SOAP response and use those values as variables

Cheers,

Joerg

www.vcoportal.de - Orchestrate. Your Cloud.
0 Kudos
redsand007
Contributor
Contributor

@iiliev

I am gettign a 415 error now which is indicating something is incorrect with the formatting.  Is there any way to go about determining how to pass the correct format?

0 Kudos
iiliev
VMware Employee
VMware Employee

Error 415 is not a formatting error but 'unsupported media type'.

When creating the PUT operation, what value did you provide in Content type input field? Also, if you are invoking this operation via workflow like Invoke a REST operation, what value did you provide in Accept Headers input field?

0 Kudos
redsand007
Contributor
Contributor

I've tried it a number of diffent ways without a successful result, but the latest is the following:

var request = restHost.createRequest(callmethod,call,callcontent);

if(callmethod != "PUT")

{

request.contentType = "application/xml";

request.setHeader("Content-Type","application/xml; charset=utf-8");

}

var response = request.execute();

 

var request = restHost.createRequest(callmethod,call,callcontent);
if(callmethod != "PUT")
{
  request.contentType = "application/xml";
 
request.setHeader("Content-Type","application/xml; charset=utf-8");
}
var response = request.execute();
0 Kudos
iiliev
VMware Employee
VMware Employee

What's the purpose of this if(callmethod != "PUT") check? Aren't you trying to execute PUT REST operation?

Also, could you try with Content-Type header that has a value "application/xml" instead of "application/xml; charset=utf-8"? Depending on how the REST server side is implemented, these two may not be equivalent.

0 Kudos
redsand007
Contributor
Contributor

@iiliev you're my new best friend!  Finally got it to work.  I modified based on your above comment and then also  took out the comments that were included in the xml body content.  Thanks again my friend.

<attribute id="0x1006e"> <!-- This attribute stores the name of the Model -->

<value>server-name.local.com</value> <!-- name to match -->

0 Kudos