How do output for tRESTClient - rest

I read some param from JSON file and for each param i should send request.
That when i true move output to any element i get errors:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
statusCode cannot be resolved or is not a field
string cannot be resolved or is not a field
body cannot be resolved or is not a field
The method getHeaders() is undefined for the type Response
at pricing.pricing_0_1.Pricing.tFileInputJSON_1Process(Pricing.java:3334)
at pricing.pricing_0_1.Pricing.tREST_1Process(Pricing.java:1783)
at pricing.pricing_0_1.Pricing.runJobInTOS(Pricing.java:4634)
at pricing.pricing_0_1.Pricing.main(Pricing.java:4366)

I had the same error messages (also having JSON files as input and output) and I found that the solution is to leave the Input, Response and Error Schema with the structures they initially had in tRESTClient.
The Input Schema contains body and string. Here you can either use tXMLMap to define the body structure (this didn't work for me) or send the JSON file as a string with tMap directly into the tRESTClient.
The Response has the schema statusCode, body and string. Again, just retrieving the string with a tMap and tLogRow will get you the output of tRestClient.
I hope this helps.

Include the statusCode variable in the JSON

I too got the same error, what I came across is since trestclient is expecting the schema inputs in form of stausCode , body and String.
Whereas the input is fed as key and value pair of schema. So we are getting error as enter image description here
So I used a tconvertType and converted the outgoing row from tconverttype as stausCode , body and String, and it started working.
enter image description here
and all the errors went away.
Thanks,

Related

Send file attachment as base64Binary in SoapUI

There is an element, which is defined as base64Binary in WSDL. I attached file with ContentID ref1 and added it to SOAP request as follows:
<docBytes><xop:Include href="cid:ref1" xmlns:xop="http://www.w3.org/2004/08/xop/include"/></docBytes>
I got following error message when I try to send it:
cvc-type.3.1.2: Element 'docBytes' is a simple type, so it must have
no element information item [children]
It is working, when I paste a base64 encoded string between tags.
That is correct, I have services where a PDF is sent, and I stored the doc as base64 byte array in a property like this:
def docContent = new File("path/to/file")
def encodedDoc = docContent.bytes.encodeBase64().toString()
testRunner.testCase.setPropertyValue("encodedDoc", encodedDoc)
Then use it with:
<docBytes>${#TestCase#encodedDoc}</docBytes>
in the request.

how do I get Mirth connectorMessage.getRawData to return a string?

I am trying to get the string representation of the HL7 message input to a channel. Documentation says
var myMessage = connectorMessage.getRawData()
should give me the original unparsed HL7 message. However the type of the data returned is an object and not a string. I tried using .toString() but that doesn't work either. My javascript library code that expects a string and be able to split it fails because what's returned is not a string.
How do I get the original HL7 message string?
connectorMessage.getRawData() returns a Java string rather than a javascript string. You can convert to a javascript string by doing.
var myMessage = String(connectorMessage.getRawData())
This is true no matter what you have selected for your data type.
On the Summary tab, click on "set data types", and change your inbound connector to "Raw"....after this, connectorMessage.getRawData() should return to you a long string that is the incoming message.

Debugging Transformer Errors in Mirth Connect Server Log

Fairly new to Mirth, so looking for advice in regards to debugging/getting more information from errors reported in the Server Log in Mirth Connect. I know what channel this is originating from, but that's about it. This error is received 10 times for each message coming through. It should be noted that the channel is working properly except for this error cluttering up the logs.
The Error:
ERROR (transformer:?): TypeError: undefined is not an xml object.
What I've Tried:
Ruled out Channel Map variables (mappers), they don't have null default values, they match up with vars in the incoming xml message, even changed to Javascript transformers to modify the catch to try to narrow down the issue, but no luck.
Modified external javascript source files to include more error handling (wrapped each file in a try/catch that would log with identifying info) but this didn't change the result at all.
Added a new Alert to send info if errors are received, but this alert never fired.
Anything else to try? Thanks for any/all help!
This is a Rhino message that happens when you use an e4x operator on a variable that isn't an xml object. The following two samples will both throw the same error you are seeing when obj is undefined. Otherwise, 'undefined' in your error will be replaced with obj.toString();
// Putting a dot between the variable and () indicates an xml filter
// instead of a function call
obj.('test');
// Two consecutive dots returns all xml descendant elements of obj
// named test instead of retrieving a property named test from obj.
obj..test;

How to get data from queryResult->getFulfillmentMessages() Dialogflow v2

I am using the google/cloud-dialogflow library for php.
I can not get the data from $queryResult->getFulfillmentMessages(); I don't know how.
I have tried:
json_decode($queryResult->getFulfillmentMessages()->serializeToJsonString(), true);
But it shows me a error. I hope you can help me.
This solution worked for me. The response that is received from the queryResult is a protobuf repeated field. The payload that is required to be extracted can be accessed by calling the first element of the repeated field and serializing it to JSON string then decoding it.
json_decode($queryResult->getFulfillmentMessages()[0]->serializeToJsonString(), true);
This will give the payload in array format using which you can perform your operations on it.

Aggregation Correlation Strategy based on XML Payload

Issue: How to correlate messages for an aggregator based on a XML value in the payload? I have a scenerio where I call a third party application and it only gives back an xml response. Based on an xml value in the payload I would like to correlate the messages to produce a single response back to the consumer.
Example using Header Attribute
#CorrelationStrategy
public Object correlate(Message message) throws JMSException {
return message.getHeaders().get("JMSXUserID");
}
Solution Notes:
As described below and referenced in the spring documentation for xml payload support.
http://docs.spring.io/spring-integration/reference/html/xml.html#xpath-spel-function
Sample Config Applied:
<aggregator
id="agg"
input-channel="jmsInChannel"
output-channel="outputChannel"
ref="AggregatorPOJO"
method="combineResponesMessages"
correlation-strategy-expression="#xpath(payload, '/test/name')"
release-strategy="AggregatorPOJO"
release-strategy-method="isComplete"/>
This will correlate the following xml.
<test><name>test1</name></test>
Take a look if #xpath() SpEL function can help you, for example:
correlation-strategy-expression="#xpath(payload, '/name')"
where payload is a payload in some XML representation of messages to correlated and /name is an XPath against that payload.
You should be sure that spring-integratrion-xml jar is on your CLASSPATH.
You would have to parse the XML; you might be able to use a simple regex Pattern or you might have to convert the payload to a DOM for more complex situations.