Announcement Announcement Module
Collapse
No announcement yet.
expected-response-type org.w3c.dom.Document issue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • expected-response-type org.w3c.dom.Document issue

    Hello. I have been using Mule for quite some time but based on their recent releases which includes several bugs, i gave SI a shot and it's very impressive. While playing around with http:outbound gateway i encountered an issue. What i was trying to do is get the XML by calling the rest URL and then pass it to my unmarshaller channel so i get back the Object instead of String. This did not work as i keep getting Object cannot be cast to String as my expected-response-type was set to String. So reading the docs i decided to use org.w3c.dom.Document as expetced-response-type. However, i keep getting httpmessage is not configure exception. It was very annoying as i could not find any threads or documentation on it on why do i need to configure anything else when i told my gateway that my response Object is going to be a Document object. So i ended up writing a transformer and converting that String payload to a Document object.

    In mule once you define the response for your outbound then that is your message. No extra configuration needed. So my question is why do we need this extra configuration when the reply is a Document object in our http outbound gateway ?

  • #2
    Hi

    I don't have a lot of free time to try some solution on the matter, but I share my thought with you.
    If you say
    then pass it to my unmarshaller
    than I suggest to try as expetced-response-type your domain class istead of org.w3c.dom.Document. On the background by this value will be determined some instance of org.springframework.http.converter.xml.AbstractXml HttpMessageConverter, which will process the HTTP response in the RestTemplate and return from gateway your domain object as Message payload.
    it would be nice, if your marshaller is JAXB and you place into expetced-response-type class marked with @RootElement.
    Otherwise you should overwrite message-converters with provided MarshallingHttpMessageConverter, because it isn't as default one in the RestTemplate's messageConverters List.

    Hope this help...

    Take care,
    Artem Bilan

    Comment


    • #3
      Hello Cleric. I forgot to tell you that i did try putting my JaxB annotation class name in the expected response type and i got the followin exception 'Failed to create source for payload type [ Your JaxB Annotation Class ]. Looking at the stacktrace and the class which threw the exception class DomSourceFactory and method createSource source parameter is always null

      Code:
      public Source createSource(Object payload) {
      		Source source = null;
      		if (payload instanceof Document) {
      			source = createDomSourceForDocument((Document) payload);
      		}
      		else if (payload instanceof String) {
      			source = createDomSourceForString((String) payload);
      		}
      		else if (payload instanceof File) {
      			source = createDomSourceForFile((File) payload);
      		}
      		if (source == null) {
      			throw new MessagingException("failed to create Source for payload type [" +
      					payload.getClass().getName() + "]");
      		}
      		return source;
      	}

      Comment


      • #4
        Err. So stupid that i was sending the output of the http outbound gateway to another reply channel which was using the unmarshal transformer and was causing the issue when putting the class name in expected response type. Thank you cleric. It's working fine.

        Comment

        Working...
        X