Mirth Transformer Error: prefix for element is not bound - hl7

I'm getting the following error when trying to convert HL7v3 to HL7v2
The message passed in is:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<PRPA_IN201306UV02 xmlns="urn:hl7-org:v3" xmlns:ns2="urn:gov:hhs:fha:nhinc:common:nhinccommon" xmlns:ns3="urn:gov:hhs:fha:nhinc:common:patientcorrelationfacade" xmlns:ns4="http://schemas.xmlsoap.org/ws/2004/08/addressing" ITSVersion="XML_1.0">
<id extension="4ae5403:12752e71a17:-7b52" root="1.1.1"/>
...
</PRPA_IN201306UV02>
</S:Body>
</S:Envelope>
The error I get is:
ERROR-300: Transformer error
ERROR MESSAGE: Error evaluating transformer
com.webreach.mirth.server.MirthJavascriptTransformerException:
CHANNEL: v3v2ConversionResponseMessage
CONNECTOR: sourceConnector
SCRIPT SOURCE:
LINE NUMBER: 5
DETAILS: TypeError: The prefix "S" for element "S:Envelope" is not bound.
at com.webreach.mirth.server.mule.transformers.JavaScriptTransformer.evaluateScript(JavaScriptTransformer.java:460)
at com.webreach.mirth.server.mule.transformers.JavaScriptTransformer.transform(JavaScriptTransformer.java:356)
at org.mule.transformers.AbstractEventAwareTransformer.doTransform(AbstractEventAwareTransformer.java:48)
at org.mule.transformers.AbstractTransformer.transform(AbstractTransformer.java:197)
at org.mule.transformers.AbstractTransformer.transform(AbstractTransformer.java:200)
at org.mule.impl.MuleEvent.getTransformedMessage(MuleEvent.java:251)
at org.mule.routing.inbound.SelectiveConsumer.isMatch(SelectiveConsumer.java:61)
at org.mule.routing.inbound.InboundMessageRouter.route(InboundMessageRouter.java:83)
at org.mule.providers.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.java:493)
at org.mule.providers.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:272)
at org.mule.providers.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:231)
at com.webreach.mirth.connectors.vm.VMMessageReceiver.getMessages(VMMessageReceiver.java:207)
at org.mule.providers.TransactedPollingMessageReceiver.poll(TransactedPollingMessageReceiver.java:108)
at org.mule.providers.PollingMessageReceiver.run(PollingMessageReceiver.java:90)
at org.mule.impl.work.WorkerContext.run(WorkerContext.java:290)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
at java.lang.Thread.run(Unknown Source)
When I remove the S: tag in front of the Envelope and Body and redefine the namespace to default, it gives me a new error
TypeError: The prefix "xsi" for attribute "xsi:nil" associated with an element type "targetMessage" is not bound."
This is referring to
<targetMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:nil="true"/>
As if Mirth can't handle the namespaces being defined on the same line as the first use of that element.
Any suggestions would be useful

I had to uncheck the "Strip Namespace" property on my incoming transformer.

To add to the solution, you'll have to ensure that you Strip Namespace from:
the Source Transformer's Inbound AND Outbound Message Template
the Destination Transformer's Inbound Message Template
The Inbound:

Related

XML fails on  character

When requesting data from my remote server it responds with a value inside a node with the following token , making the parsing process to fail. I manually removed the guilty string and it started working.
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
...
<sFName>Bradley</sFName>
<sLName>Libbra</sLName>
...
Token: 
The error raised by Savon is:
Savon::InvalidResponseError: Unable to parse response body:
 (aka INFORMATION SEPARATOR TWO) is not an allowed character in XML :
[2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
Therefore your data is not XML, and any conformant XML processor must report an error such as the one you received.
You must repair the data by removing any illegal characters by treating it as text, not XML, manually or automatically before using it with any XML libraries.
See also How to parse invalid (bad / not well-formed) XML?
My original question was around Savon ruby gem. I sorted this out by changing the default response parser to :rexml. It now parses the invalid character and does not raises an exception.
But right answer would be to parse the malformed XML or ask the provider to fix it. Thanks #kjhughes

XSD validation fails with UndeclaredPrefix when using AxiomSoapMessageFactory in Spring WS

I'm building a contract-first SOAP web service with spring-ws 2.2.3. My XML Schema uses extensions, leading to xsi:type= attributes in the XML requests. Since some respones can be very large (30MB), I'm using a AxiomSoapMessageFactory instead of the default SaajSoapMessageFactory, as suggested in the Spring WS docs. I validate incoming requests with a PayloadValidatingInterceptor:
PayloadValidatingInterceptor interceptor = new PayloadValidatingInterceptor();
interceptor.setSchema(new ClassPathResource("format-service.xsd"));
interceptor.setValidateRequest(true);
interceptor.setValidateResponse(false);
My problem is that I get spurious validation errors, depending on where in the XML the namespace is declared: if it's declared in the payload, then everything works fine:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" >
<soapenv:Header/>
<soapenv:Body>
<sch:formatRequest xmlns:sch="http://example.com/springws/extension/schema">
<sch:value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="sch:currencyType">
<sch:amount>1000</sch:amount>
<sch:currency>EUR</sch:currency>
</sch:value>
</sch:formatRequest>
</soapenv:Body>
</soapenv:Envelope>
But as soon as I move the sch namespace declaration up to the Envelope:
<soapenv:Envelope xmlns:sch="http://example.com/springws/extension/schema" ...>
validation fails and I receive a SOAP Fault:
<faultcode>soapenv:Client</faultcode>
<faultstring xml:lang="en">Validation error</faultstring>
<detail>
<spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">UndeclaredPrefix: Cannot resolve 'sch:currencyType' as a QName: the prefix 'sch' is not declared.</spring-ws:ValidationError>
<spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">cvc-elt.4.1: The value 'sch:currencyType' of attribute 'http://www.w3.org/2001/XMLSchema-instance,type' of element 'sch:value' is not a valid QName.</spring-ws:ValidationError>
<spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">cvc-type.2: The type definition cannot be abstract for element sch:value.</spring-ws:ValidationError>
<spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">UndeclaredPrefix: Cannot resolve 'sch:currencyType' as a QName: the prefix 'sch' is not declared.</spring-ws:ValidationError>
<spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">cvc-attribute.3: The value 'sch:currencyType' of attribute 'xsi:type' on element 'sch:value' is not valid with respect to its type, 'QName'.</spring-ws:ValidationError>
<spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">cvc-complex-type.2.1: Element 'sch:value' must have no character or element information item [children], because the type's content type is empty.</spring-ws:ValidationError>
</detail>
It appears like a bug in the AxiomSoapMessageFactory / Axiom implementation to me (namespace context is lost), as both requests validate fine when using the SaajSoapMessageFactory. Note that the validation only fails on the xsi:type= attribute. The same namespace is recognized correctly for elements.
I cannot use SaajSoapMessageFactory due to high memory consumption for large responses. I found similar problems described in the Spring forum and on SO, but no solution. Thanks for help!
The reason is that Spring-WS uses OMContainer#getXMLStreamReader(). Instead it should use OMContainer#getXMLStreamReader(boolean, OMXMLStreamReaderConfiguration) and set the preserveNamespaceContext property to true in the OMXMLStreamReaderConfiguration object.
You should file a bug for Spring-WS, or even better, fix the issue and submit a pull request.

twilio Message tag not working

Why is this failing?
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Message>
<Body>Store Location: 123 Easy St.</Body>
<Media>https://demo.twilio.com/owl.png</Media>
</Message>
</Response>
I am receiving the following error:
Warning: 12200 - Schema validation warning
Parse error found on line 1 of the Raw Response
https://www.twilio.com/user/account/log/calls/CA7920533e98ffed29426d29e7e27746c8
I did a diff with the original example, and it's EXACTLY the same!
Original example is listed here:
https://www.twilio.com/docs/api/twiml/sms/message
I looks like you are building your application with Twilio as a Voice call application instead a SMS Message application.
The url https://www.twilio.com/user/account/log/calls/CA7920533e98ffed29426d29e7e27746c8 suggested that you are accesing your application as a voice call application, if not it would be https://www.twilio.com/user/account/log/messages/{some other id}.

Mule Box Connector - Invalid Key Type / Message payload is of type String

I'm trying to write a Mule flow that uses the Box connector. I'm able to go to http://localhost:8081/auth and authorize successfully. But as soon as I create a file in my box account I get "Failed to Invoke getEvents. Message payload is of type: String." and in the Root Exception Trace I get: "Invalid Key Type"
Mule Flow (based on: https://github.com/mulesoft/box-connector/blob/master/demo/src/main/app/box-connector-demo.xml)
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"
xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:objectstore="http://www.mulesoft.org/schema/mule/objectstore" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:box="http://www.mulesoft.org/schema/mule/box" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="CE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/objectstore http://www.mulesoft.org/schema/mule/objectstore/1.0/mule-objectstore.xsd
http://www.mulesoft.org/schema/mule/box http://www.mulesoft.org/schema/mule/box/2.0/mule-box.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd">
<box:config name="Box" clientId="removed" clientSecret="removed" doc:name="Box">
<box:oauth-callback-config domain="localhost" localPort="8081" path="callback" remotePort="8081"/>
</box:config>
<objectstore:config name="ObjectStore" objectStore-ref="_defaultInMemoryObjectStore" doc:name="ObjectStore"/>
<flow name="Authorize" doc:name="Authorize">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP" path="auth"/>
<box:authorize config-ref="Box" doc:name="Authorize" />
</flow>
<flow name="longPolling" doc:name="longPolling">
<box:listen-events config-ref="Box" doc:name="Box (Streaming)"/>
<set-variable variableName="defaultValue" value="0" doc:name="Variable"/>
<objectstore:retrieve config-ref="ObjectStore" key="streamPosition" defaultValue-ref="#[flowVars['defaultValue']]" doc:name="ObjectStore"/>
<box:get-events config-ref="Box" streamPosition="#[payload]" accessTokenId="#[message.inboundProperties['boxAccessTokenId']]" doc:name="Box" />
<objectstore:store config-ref="ObjectStore" key="streamPosition" value-ref="#[payload.nextStreamPosition]" overwrite="true" doc:name="ObjectStore"/>
<scripting:transformer doc:name="Groovy">
<scripting:script engine="Groovy"><![CDATA[return payload.entries.findAll{it.eventType =='ITEM_DOWNLOAD' || it.eventType == 'ITEM_PREVIEW'}
]]></scripting:script>
</scripting:transformer>
<scripting:transformer doc:name="Groovy">
<scripting:script engine="Groovy"><![CDATA[return payload.findAll{it.source?.type == "file" && it.source?.parent.id == "0"}
]]></scripting:script>
</scripting:transformer>
<foreach doc:name="Foreach">
<logger message="Box user #[payload.createdBy.login] has seen the file #[payload.source.name]" level="ERROR" doc:name="Logger"/>
</foreach>
</flow>
</mule>
Here's the full error:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Started app 'boxtest' +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
WARN 2014-02-06 10:00:35,607 [Box Long Polling thread for endpont http://2.realtime.services.box.net/subscribe?channel=removed&stream_type=all] org.mule.DefaultMuleMessage: setProperty(key, value) called with null value; removing key: boxAccessTokenId; please report the following stack trace to dev#mule.codehaus.org
java.lang.Throwable
at org.mule.DefaultMuleMessage.setProperty(DefaultMuleMessage.java:457)
at org.mule.DefaultMuleMessage.addProperties(DefaultMuleMessage.java:1249)
at org.mule.DefaultMuleMessage.<init>(DefaultMuleMessage.java:174)
at org.mule.modules.box.processors.AbstractListeningMessageProcessor.process(AbstractListeningMessageProcessor.java:76)
at org.mule.modules.box.lp.LongPollingClient$1.run(LongPollingClient.java:63)
at java.lang.Thread.run(Unknown Source)
ERROR 2014-02-06 10:00:35,823 [[boxtest].longPolling.stage1.02] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Failed to invoke getEvents. Message payload is of type: String
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Invalid key type (java.lang.RuntimeException)
org.mule.modules.box.oauth.BoxConnectorOAuthClientFactory:28 (null)
2. Failed to invoke getEvents. Message payload is of type: String (org.mule.api.MessagingException)
org.mule.modules.box.processors.GetEventsMessageProcessor:155 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.RuntimeException: Invalid key type
at org.mule.modules.box.oauth.BoxConnectorOAuthClientFactory.makeObject(BoxConnectorOAuthClientFactory.java:28)
at org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:1179)
at org.mule.modules.box.oauth.BoxConnectorOAuthManager.acquireAccessToken(BoxConnectorOAuthManager.java:339)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
This looks like a bug to me: box:get-events is supposed to use property boxAccessTokenId as authentication token, there is a warning that the property is not set due to a null value, and when I look at the source code for the BoxConnector class where the value is coming from, there is a reference to a private variable accessTokenIdentifier which is never set. I reported this to the Mule dev address.
...I have used the Box connector recently with both the Mule 3.x and 4.x runtimes. I was pleased with the ease of setup, once I understood what's needed.
I recommend giving either a try now.

Number format exception in JIRA

I am getting number format exception while trying to get the issue details by using id.
RemoteIssue ri = jira.getIssueById(JIRAtoken, string.Format(IssueKey));
here jiratoken is string. But giving exception. Any one have any idea?
I had the same problem, using the SOAP Web Service API of JIRA (4).
I solved it by using getIssue instead of getIssueById. With getIssue, JIRA expects the key like MYPROJECT-3.
Now I send a request like this, and it works :
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://soap.rpc.jira.atlassian.com">
<soapenv:Header/>
<soapenv:Body>
<soap:getIssue soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<in0 xsi:type="xsd:string">MyAuthToken</in0>
<in1 xsi:type="xsd:string">MYPROJECT-1</in1>
</soap:getIssue>
</soapenv:Body>
</soapenv:Envelope>

Resources