我从ws:consumer和mulexml:xml-to-dom-transformer获得转义的XML结果,我不知道如何通过mule组件取消它,或者可能是我做错了什么? 这是相关的流程:
<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"/>
和我的结果:
........<?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" ..........
我该怎么办?
我使用了mule anypoint studio 6.1.2
更新:
基于https://docs.mulesoft.com/mule-user-guide/v/3.6/web-service-consumer
我在dw:transform-message
之前和之后使用了ws:consumer
,并使用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>
但是这个错误发生了:
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)
答案 0 :(得分:1)
根据我的理解,转换webservice结果是基于您的要求而不是必需的步骤。消费者之后真的需要变压器吗?尝试在消费者之后移除变压器并查看修复问题。在消费者之后尝试使用和不使用变压器进行调试并验证结果。 对于xml转义字符问题,我在mule exchange(https://www.mulesoft.com/exchange#!/global-global-weather-wsdl?types=WSDL)上尝试了SOAP webservice并得到了类似于转义字符的结果,但原因是,webservice响应(但是你的结果看起来不同,即使你的结果中有转义字符xml声明也来自数据库,带有转义字符可能是mule不是这个原因。我在webservicex.net(http://webservicex.net/New/Home/ServiceDetail/23)上尝试了不同的服务,它完美无缺地运行。