-1

I am getting this error:

TypeError: The prefix "types" for element "types:ReceiveMessageResponse" is not bound.
at com.orchestral.rhapsody.modules.standard.filters.executescript.ExecuteScript.doProcessMessage(ExecuteScript.java:9)

With this code:

var next = output.append(input[0]);

var output = 
<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/ xmlns:soapenc=http://schemas.xmlsoap.org/soap/encoding/ xmlns:tns=http://www.show.scot.nhs.uk/sci/gateway/messaging2.0 xmlns:types=http://www.show.scot.nhs.uk/sci/gateway/messaging2.0 xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:xsd=http://www.w3.org/2001/XMLSchema'>
  <soap:Body soap:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
    <types:ReceiveMessageResponse>
      <ReceiveMessageResult href="#id1"/>
    </types:ReceiveMessageResponse>
    <types:GatewayAck id="id1" xsi:type="types:GatewayAck">
      <Code xsi:type="xsd:int">0</Code>
      <Detail xsi:type="xsd:string"/>
      <Source xsi:type="xsd:string"/>
      <UserMsg xsi:type="xsd:string"/>
    </types:GatewayAck>
  </soap:Body>
</soap:Envelope>
next.xml = output;

I tried creating one more tag for Types but it did not worked.

kjhughes
  • 106,133
  • 27
  • 181
  • 240
  • Does this answer your question? [xml schema validation error "prefix is not bound"](https://stackoverflow.com/questions/9473380/xml-schema-validation-error-prefix-is-not-bound) – Lenka Aug 04 '23 at 13:17
  • 1
    Typo: The syntax is `attributeName='value' otherAttributeName='otherValue'` **not** `attributeName='value otherAttributeName=otherValue'` — You don't have enough quotes. The syntax highlighting of the code you put in your question highlights this problem, that's why `xmlns:types` is shown in green (part of an attribute value) instead of purple (attribute name). – Quentin Aug 04 '23 at 13:47

1 Answers1

-1

Namespace prefixes such as types must be declared. For example, adding the following declaration,

xmlns:types="http://example.com/types"

to any common ancestor element in the document / message would place all types prefixed components in the http://example.com/types namespace.


Update: Per @Quentin's eagle eye, the declaration is there, but many of the namespace URLs are not properly delimited with quotes:

Change

<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/
               xmlns:soapenc=http://schemas.xmlsoap.org/soap/encoding/ 
               xmlns:tns=http://www.show.scot.nhs.uk/sci/gateway/messaging2.0 
               xmlns:types=http://www.show.scot.nhs.uk/sci/gateway/messaging2.0
               xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
               xmlns:xsd=http://www.w3.org/2001/XMLSchema'>

to

<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'
               xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
               xmlns:tns='http://www.show.scot.nhs.uk/sci/gateway/messaging2.0'
               xmlns:types='http://www.show.scot.nhs.uk/sci/gateway/messaging2.0'
               xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
               xmlns:xsd='http://www.w3.org/2001/XMLSchema'>

taking care to delimit all of the namespace URLs properly.

kjhughes
  • 106,133
  • 27
  • 181
  • 240