Reputation: 382
I get the escaped XML result from ws:consumer and mulexml:xml-to-dom-transformer and I dont know how to unscape it by mule component, or may be I have done something wrong?? here is related flow:
<ws:consumer config-ref="Web_Service_Consumer" operation="Login" doc:name="Web Service Consumer"/>
<mulexml:xml-to-dom-transformer doc:name="XML to DOM" returnClass="java.lang.String"/>
and my result:
........<?xml version="1.0" encoding="UTF-8"?><LoginResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ..........
What should I do?
I used mule anypoint studio 6.1.2
UPDATE:
based on https://docs.mulesoft.com/mule-user-guide/v/3.6/web-service-consumer
I used dw:transform-message
before and after ws:consumer
and map the input and output result using DataSense
<dw:transform-message metadata:id="92383237-87b0-42ed-b794-b8f247cc3af5" doc:name="Transform Message">
<dw:input-payload mimeType="application/csv"/>
<dw:set-payload><![CDATA[%dw 1.0
%output application/xml
%namespace ns0 http://tempuri.org/
---
{
ns0#Login: {
ns0#Username: payload.Username,
ns0#Password: payload.pass
}
}]]></dw:set-payload>
</dw:transform-message>
<ws:consumer config-ref="Web_Service_Consumer" operation="Login" doc:name="Web Service Consumer"/>
<dw:transform-message metadata:id="39ba326e-a6f4-4e3f-8de9-b42ddc0f19b2" doc:name="Transform Message">
<dw:set-payload><![CDATA[%dw 1.0
%output application/xml
%namespace ns0 http://tempuri.org/
%namespace ns1 http://www.w3.org/2001/XMLSchema
%namespace ns2 http://www.w3.org/XML/1998/namespace
---
{
ns0#LoginResponse: {
ns0#LoginResult: {
ns1#schema @(targetNamespace: payload.ns0#LoginResponse.ns0#LoginResult.ns1#schema.@targetNamespace , version: payload.ns0#LoginResponse.ns0#LoginResult.ns1#schema.@version , finalDefault: payload.ns0#LoginResponse.ns0#LoginResult.ns1#schema.@finalDefault , blockDefault: payload.ns0#LoginResponse.ns0#LoginResult.ns1#schema.@blockDefault , attributeFormDefault: payload.ns0#LoginResponse.ns0#LoginResult.ns1#schema.@attributeFormDefault ,
elementFormDefault: payload.ns0#LoginResponse.ns0#LoginResult.ns1#schema.@elementFormDefault , id: payload.ns0#LoginResponse.ns0#LoginResult.ns1#schema.@id , lang: payload.ns0#LoginResponse.ns0#LoginResult.ns1#schema.@ns2#lang): {
(payload.ns0#LoginResponse.ns0#LoginResult.ns1#schema.*ns1#notation map ((notation , indexOfNotation) -> {
ns1#notation: {
}
})),
(payload.ns0#LoginResponse.ns0#LoginResult.ns1#schema.*ns1#attribute map ((attribute , indexOfAttribute) -> {
ns1#attribute: {
}
})),
(payload.ns0#LoginResponse.ns0#LoginResult.ns1#schema.*ns1#element map ((element , indexOfElement) -> {
ns1#element: {
}
})),
(payload.ns0#LoginResponse.ns0#LoginResult.ns1#schema.*ns1#attributeGroup map ((attributeGroup , indexOfAttributeGroup) -> {
ns1#attributeGroup: {
}
})),
(payload.ns0#LoginResponse.ns0#LoginResult.ns1#schema.*ns1#group map ((group , indexOfGroup) -> {
ns1#group: {
}
})),
(payload.ns0#LoginResponse.ns0#LoginResult.ns1#schema.*ns1#complexType map ((complexType , indexOfComplexType) -> {
ns1#complexType: {
}
})),
(payload.ns0#LoginResponse.ns0#LoginResult.ns1#schema.*ns1#simpleType map ((simpleType , indexOfSimpleType) -> {
ns1#simpleType: {
}
})),
(payload.ns0#LoginResponse.ns0#LoginResult.ns1#schema.*ns1#annotation map ((annotation , indexOfAnnotation) -> {
ns1#annotation: {
}
})),
(payload.ns0#LoginResponse.ns0#LoginResult.ns1#schema.*ns1#redefine map ((redefine , indexOfRedefine) -> {
ns1#redefine: {
}
})),
(payload.ns0#LoginResponse.ns0#LoginResult.ns1#schema.*ns1#import map ((import , indexOfImport) -> {
ns1#import: {
}
})),
(payload.ns0#LoginResponse.ns0#LoginResult.ns1#schema.*ns1#include map ((include , indexOfInclude) -> {
ns1#include @(id: include.@id , schemaLocation: include.@schemaLocation): {
ns1#annotation: include.ns1#annotation
}
}))
}
}
}
}]]></dw:set-payload>
</dw:transform-message>
but this error ocuured:
Root Exception stack trace:
javax.xml.stream.XMLStreamException: Trying to bind URI http://www.w3.org/XML/1998/namespace to prefix "{0}" (can only bind to xml)
Upvotes: 1
Views: 461
Reputation: 300
As per my understanding transforming webservice result is based on your requirement and it’s not required step. Do you really need transformer after consumer? Try removing the transformer after consumer and see fix the issue. Also try to debug with and without transformer after consumer and verify the results. For xml escape character issue, I tried the SOAP webservice on mule exchange (https://www.mulesoft.com/exchange#!/global-global-weather-wsdl?types=WSDL) and got results similar with escape characters, but reason for that is, webservice response (but your results looks different even your result have escape characters in xml declaration as well) is coming from database with escape characters probably mule is not reason for that. I tried different service on webservicex.net (http://webservicex.net/New/Home/ServiceDetail/23) and it worked perfectly without any issue.
Upvotes: 1