wso2 ESB xslt transformation issue - wso2-esb

I am hoping that somebody can give some guidance with an xslt issue I am having. I am recieving a generic XML message into a proxy service, I then need to wrap the xml in a soap message and forward it on to an axis2 jms service.
I have tested the stylehseet against my xml using both a saxon and xalan engine and they both work as expected but wso2 will not accept it I get an error WstxParsingException: String ']]>' not allowed in textual content if I have the CDATA section (which I need).
any advice would be much appreciated
thanks
Paul
The stylesheet is as follows
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:klr="http://klr.com">
<xsl:output method="xml" indent="yes" encoding="UTF-8" cdata-section-elements="klr:legaldocument"/>
<xsl:template match="/">
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:klr="http://klr.com">
<SOAP-ENV:Body>
<klr:Hypertext>
<klr:legaldocument>
<xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text>
<xsl:apply-templates select="*"/>
<xsl:text disable-output-escaping="yes">]]></xsl:text>
</klr:legaldocument>
</klr:Hypertext>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</xsl:template>
<xsl:template match="node()">
<xsl:element name="{local-name(.)}">
<xsl:copy-of select="#*"/>
<xsl:apply-templates select="node()|*"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

Just your second template does not work. Here is the working complete stylesheet:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:klr="http://klr.com">
<xsl:output method="xml" indent="yes" encoding="UTF-8" cdata-section-elements="klr:legaldocument"/>
<xsl:template match="/">
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:klr="http://klr.com">
<SOAP-ENV:Body>
<klr:Hypertext>
<klr:legaldocument>
<xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text>
<xsl:apply-templates select="*"/>
<xsl:text disable-output-escaping="yes">]]></xsl:text>
</klr:legaldocument>
</klr:Hypertext>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</xsl:template>
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
For more information see this entry here.

Related

Asp.net core Database Connectivity not working on Local IIS Hosting

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="Defaultconnection" value="Server=INNO1-395LFP\SQLEXPRESS;Database=ASK_DB;uid=sa;password=Sa#123456;Trusted_Connection=True;" /></appSettings>
</configuration>
This is my app.config file and I am not able to connect to database in asp.net core in Local IIS Hosting

ESB Mule - how to see the dynamic URL which is used to hit in the HTTP component

I am new to mule ESB.
I have designed a flow like below.
I like to see the request URL built dynamically to hit the REST API. I have tried debugging a flow. I have set a breakpoint on "Call_HTTPS_REST_API" http component. There i can see the payload. But URL i could not see any where.
Please help me to find the dynamic URL which is used to hit the service.
Note - I have tried using system.out.println to print the variable (dynamicEndpoint). Though i like to see the url which is used to hit the service.
Please find the flow configuration xml.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:wmq="http://www.mulesoft.org/schema/mule/ee/wmq" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:http="http://www.mulesoft.org/schema/mule/http" 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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="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/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/wmq http://www.mulesoft.org/schema/mule/ee/wmq/current/mule-wmq-ee.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8085" basePath="/mule" doc:name="HTTP Listener Configuration"/>
<http:request-config name="HTTP_Request_Configuration" host="#[dynamicEndpoint]" port="443" doc:name="HTTP Request Configuration" protocol="HTTPS" >
</http:request-config>
<flow name="secondflowFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<custom-transformer class="com.mule.URLBuilding.BuildURL" doc:name="Java"/>
<http:request config-ref="HTTP_Request_Configuration" method="POST" path="/" doc:name="Call_HTTPS_REST_API">
<http:success-status-code-validator values="0..599"/>
</http:request>
</flow>
</mule>
Just add a logger and log #[dynamicEndpoint]
<logger message="#[dynamicEndpoint]" level="INFO" doc:name="Logger"/>
If you create a variable you should see it in the debugger on the variables tab, at the moment you probably don't have a variable or maybe you create in in your Java code. Otherwise create a flowVars with the value #[dynamicEndpoint]

webHttpBinding endpoint adds temuri.org namespace in WSDL if bindingNamespace attribute is excluded

I have a WCF service that needs to be exposed over a SOAP endpoint (wsHttpBinding) and a REST endpoint (webHttpBinding). I have included Names and Namespaces on the relevant attributes to aid in versioning (tempuri.org should be completely eliminated from the WSDL). For some reason, if I don't add a bindingNamepace attribute on the webHttpBinding endpoint, it adds a tempuri.org namespace in the WSDL. Example WSDL output is below.
WSDL without bindingNamespace -
<wsdl:definitions name="State" targetNamespace="http://example.com/services/masterdat/state/2012/02/05"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:tns="http://example.com/services/masterdata/state/2012/02/05"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:i0="http://tempuri.org/"
xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract"
xmlns:wsa10="http://www.w3.org/2005/08/addressing"
xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata">
WSDL with bindingNamespace -
<wsdl:definitions name="State" targetNamespace="http://example.com/services/masterdata/state/2012/02/05"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:tns="http://example.com/services/masterdata/state/2012/02/05"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract"
xmlns:wsa10="http://www.w3.org/2005/08/addressing"
xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata">
Here is my web.Config for the endpoints. I am using WCFExtras to flatten my WSDLs (hence the behaviorConfiguration on the wsHttpBinding endpoint), but the behavior is the same without it.
<services>
<service name="MasterDataExample.Services.StateService">
<!-- bindingConfiguration="defaultWsBinding" -->
<endpoint address="soap"
behaviorConfiguration="flatWsdl"
binding="wsHttpBinding"
bindingNamespace="http://example.com/services/masterdata/state/2012/02/05"
contract="MasterDataExample.Services.IStateService"
name="soap" />
<!-- -->
<endpoint address="json"
behaviorConfiguration="json"
binding="webHttpBinding"
bindingNamespace="http://example.com/services/masterdata/state/2012/02/05"
contract="MasterDataExample.Services.IStateService"
name="ajax" />
</service>
</services>
I've loaded up WCFExtras in my solution and looked at the WsdlExporter to see if I can find the mention of tempuri.org with no success. I've also used XSharper.Core to dump the object graph to see if I could find it. It isn't there.
Has anyone experienced this before? As a work around, I'll include the bindingNamespace on the webHttpBinding endpoint to keep the WSDL clean, but I'd like to know why this is occurring.
Thanks!
It seems that the BindingNamespace is required in your endpoint configuration to remove the tempuri.org namespace completely from your WSDL. See this post (item 3).

NServiceBus: Trouble getting PubSub working with Distributor

I'm using NServiceBus 2.5 and trying to get a simplified version of the NServiceBus PubSub sample working with the distributor. The simplification:
1 Publisher
Distributor
1 Subscriber
All of this is on a single machine.
I would like to get this working before I move on to more complex things like multiple subscribers behind a single distributor, multiple machines, etc.
First I got the simplified pub sub example working without the distributor (i.e 1 pub and 1 sub - and I got that working fine).
As I understand it, the way it should work is:
The distributor defines its own control and data queues.
The publisher has it's control queue, but no other config refers to this queue. The publisher refers to the distributes data queue.
The subscriber refers to the distributors data and control queues.
I've not been able to get the simplified pub-sub distributor working with this config. I've done some debugging of the publisher and what I've found is that the publisher's Bus.Publish doesn't find any subscribers to publish to.
Any ideas what I'm doing wrong and what I need to do to get this working?
Here's configs for each of those:
Publisher:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
</configSections>
<MsmqTransportConfig InputQueue="MyPublisherInputQueue" ErrorQueue="error" NumberOfWorkerThreads="1" MaxRetries="5" />
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="MyMessages" Endpoint="distributorDataBus" />
</MessageEndpointMappings>
</UnicastBusConfig>
</configuration>
Distributor
<add key="DataInputQueue" value="distributorDataBus"/>
<add key="ControlInputQueue" value="distributorControlBus"/>
<add key="ErrorQueue" value="error"/>
<add key="StorageQueue" value="distributorStorage"/>
<add key="NameSpace" value="http://www.UdiDahan.com"/>
<!-- relevant for a Serialization of "interfaces" or "xml" -->
<add key="Serialization" value="xml"/>
<!-- can be either "xml", or "binary" -->
</appSettings>
</configuration>
Subscriber
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
</configSections>
<MsmqTransportConfig
InputQueue="Subscriber1InputQueue_1"
ErrorQueue="error"
NumberOfWorkerThreads="1"
MaxRetries="5"
/>
<UnicastBusConfig DistributorControlAddress="distributorControlBus" DistributorDataAddress="distributorDataBus">
<MessageEndpointMappings />
</UnicastBusConfig>
</configuration>
Ok, I finally got this working. The key clue came from here: http://tech.groups.yahoo.com/group/nservicebus/message/8525
Basically, the subscriber needs to be pointed to the publisher by adding this section:
<UnicastBusConfig DistributorControlAddress="distributorControlBus" DistributorDataAddress="distributorDataBus">
<MessageEndpointMappings>
<add Messages="MyMessages" Endpoint="MyPublisherInputQueue" />
</MessageEndpointMappings>
</UnicastBusConfig>
I initially thought that this is making the subscriber register directly with the publisher, but no. I tested that out with two different subscribers pointed to the same distributor and noted that only one of the subscribers gets any single event published.

MSBuild XmlMassUpdate Task

I wanted to ask a quick question regarding the behaviour of the MSBuild task XmlMassUpdate.
Has anyone found that the task will only copy unique nodes over to the content XML? For example, if I have a client node which has multiple children called endpoint, then it will only mass copy the first endpoint node while eliminating all the others.
I've provided some examples below of what I'm describing, many thanks in advance.
MSBuild Task:
<Project DefaultTargets="Run" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.targets" />
<Target Name="Run">
<Delete Condition="Exists('web.config')" Files="web.config"/>
<XmlMassUpdate
ContentFile="app.config"
ContentRoot="configuration/system.servicemodel"
SubstitutionsFile="wcf.config"
SubstitutionsRoot="/system.servicemodel"
MergedFile="web.config"
/>
</Target>
</Project>
Content:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.servicemodel/>
</configuration>
Replacement:
<?xml version="1.0" encoding="utf-8" ?>
<system.servicemodel>
<client>
<endpoint binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_LargeMessage"
contract="ClaimsService.IClaimsService"
name="WSHttpBinding_IClaimsService">
</endpoint>
<endpoint binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_LargeMessage"
contract="LateCertificationAdminService.ILateCertificationAdminService"
name="WSHttpBinding_ILateCertificationAdminService">
</endpoint>
</client>
</system.servicemodel>
Output:
<?xml version="1.0" encoding="utf-8" ?>
<system.servicemodel>
<client>
<endpoint binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_LargeMessage"
contract="ClaimsService.IClaimsService"
name="WSHttpBinding_IClaimsService">
</endpoint>
</client>
</system.servicemodel>
The XmlMassUpdate help section included in the MSBuildCommunityTasks help file shows examples of dealing with multiple elements that have the same name.
You need to differentiate the elements using a unique attribute, this attribute will be defined as an XmlMassUpdate "key". In your case, the name attribute will work. I believe this updated Replacement code below will fix your issue, notice the xmu attributes.
<?xml version="1.0" encoding="utf-8" ?>
<system.servicemodel>
<client xmlns:xmu="urn:msbuildcommunitytasks-xmlmassupdate">
<endpoint xmu:key="name"
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_LargeMessage"
contract="ClaimsService.IClaimsService"
name="WSHttpBinding_IClaimsService">
</endpoint>
<endpoint xmu:key="name"
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_LargeMessage"
contract="LateCertificationAdminService.ILateCertificationAdminService"
name="WSHttpBinding_ILateCertificationAdminService">
</endpoint>
</client>
</system.servicemodel>