group and add nodes in memory XML - nosql

I have below input:
<income>
<flow>
<Year>2020-2021</Year>
<Period>8</Period>
<Date>2020-11-30</Date>
<Metric>in</Metric>
<Monthly_Value>1</Monthly_Value>
</flow>
<flow>
<Year>2020-2021</Year>
<Period>8</Period>
<Date>2020-11-30</Date>
<Metric>out</Metric>
<Monthly_Value>4</Monthly_Value>
</flow>
<flow>
<Year>2020-2021</Year>
<Period>9</Period>
<Date>2020-12-31</Date>
<Metric>in</Metric>
<Monthly_Value>3</Monthly_Value>
</flow>
<flow>
<Year>2020-2021</Year>
<Period>9</Period>
<Date>2020-12-31</Date>
<Metric>out</Metric>
<Monthly_Value>2</Monthly_Value>
</flow>
<flow>
<Year>2020-2021</Year>
<Period>10</Period>
<Date>2021-01-31</Date>
<Metric>in</Metric>
<Monthly_Value>2</Monthly_Value>
</flow>
<flow>
<Year>2020-2021</Year>
<Period>10</Period>
<Date>2021-01-31</Date>
<Metric>out</Metric>
<Monthly_Value>1</Monthly_Value>
</flow>
<flow>
<Year>2020-2021</Year>
<Period>11</Period>
<Date>2021-02-28</Date>
<Metric>in</Metric>
<Monthly_Value>1</Monthly_Value>
</flow>
<flow>
<Year>2020-2021</Year>
<Period>11</Period>
<Date>2021-02-28</Date>
<Metric>out</Metric>
<Monthly_Value>3</Monthly_Value>
</flow>
<flow>
<Year>2020-2021</Year>
<Period>12</Period>
<Date>2021-03-31</Date>
<Metric>in</Metric>
<Monthly_Value>2</Monthly_Value>
</flow>
<flow>
<Year>2020-2021</Year>
<Period>12</Period>
<Date>2021-03-31</Date>
<Metric>out</Metric>
<Monthly_Value>1</Monthly_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>1</Period>
<Date>2021-04-30</Date>
<Metric>in</Metric>
<Monthly_Value>1</Monthly_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>1</Period>
<Date>2021-04-30</Date>
<Metric>out</Metric>
<Monthly_Value>2</Monthly_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>2</Period>
<Date>2021-05-31</Date>
<Metric>in</Metric>
<Monthly_Value>2</Monthly_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>2</Period>
<Date>2021-05-31</Date>
<Metric>out</Metric>
<Monthly_Value>1</Monthly_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>4</Period>
<Date>2021-07-31</Date>
<Metric>out</Metric>
<Monthly_Value>1</Monthly_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>5</Period>
<Date>2021-08-31</Date>
<Metric>in</Metric>
<Monthly_Value>3</Monthly_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>5</Period>
<Date>2021-08-31</Date>
<Metric>out</Metric>
<Monthly_Value>1</Monthly_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>6</Period>
<Date>2021-09-30</Date>
<Metric>in</Metric>
<Monthly_Value>2</Monthly_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>6</Period>
<Date>2021-09-30</Date>
<Metric>out</Metric>
<Monthly_Value>2</Monthly_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>7</Period>
<Date>2021-10-31</Date>
<Metric>in</Metric>
<Monthly_Value>2</Monthly_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>7</Period>
<Date>2021-10-31</Date>
<Metric>out</Metric>
<Monthly_Value>5</Monthly_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>8</Period>
<Date>2021-11-30</Date>
<Metric>in</Metric>
<Monthly_Value>1</Monthly_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>8</Period>
<Date>2021-11-30</Date>
<Metric>out</Metric>
<Monthly_Value>1</Monthly_Value>
</flow>
</income>
I need to group Metric & Year, sort ascending on Period first. This process generates 4 groups: 
in & 2020-2021 
in & 2021-2022
out & 2020-2021
out & 2021-2022
Then I get the previous Monthly_Value, then add new node after each Monthly_Value node as Previous_Value.
Expected output:
<income>
<flows>
<Year>2020-2021</Year>
<flow>
<Year>2020-2021</Year>
<Period>8</Period>
<Date>2020-11-30</Date>
<Metric>in</Metric>
<Monthly_Value>1</Monthly_Value>
<Previous_Value>1</Previous_Value>
</flow>
<flow>
<Year>2020-2021</Year>
<Period>9</Period>
<Date>2020-12-31</Date>
<Metric>in</Metric>
<Monthly_Value>3</Monthly_Value>
<Previous_Value>1</Previous_Value>
</flow>
<flow>
<Year>2020-2021</Year>
<Period>10</Period>
<Date>2021-01-31</Date>
<Metric>in</Metric>
<Monthly_Value>2</Monthly_Value>
<Previous_Value>3</Previous_Value>
</flow>
<flow>
<Year>2020-2021</Year>
<Period>11</Period>
<Date>2021-02-28</Date>
<Metric>in</Metric>
<Monthly_Value>1</Monthly_Value>
<Previous_Value>2</Previous_Value>
</flow>
<flow>
<Year>2020-2021</Year>
<Period>12</Period>
<Date>2021-03-31</Date>
<Metric>in</Metric>
<Monthly_Value>2</Monthly_Value>
<Previous_Value>1</Previous_Value>
</flow>
</flows>
<flows>
<Year>2021-2022</Year>
<flow>
<Year>2021-2022</Year>
<Period>1</Period>
<Date>2021-04-30</Date>
<Metric>in</Metric>
<Monthly_Value>1</Monthly_Value>
<Previous_Value>1</Previous_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>2</Period>
<Date>2021-05-31</Date>
<Metric>in</Metric>
<Monthly_Value>2</Monthly_Value>
<Previous_Value>1</Previous_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>3</Period>
<Date>2021-06-30</Date>
<Metric>in</Metric>
<Monthly_Value>2</Monthly_Value>
<Previous_Value>2</Previous_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>4</Period>
<Date>2021-07-31</Date>
<Metric>in</Metric>
<Monthly_Value>1</Monthly_Value>
<Previous_Value>2</Previous_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>5</Period>
<Date>2021-08-31</Date>
<Metric>in</Metric>
<Monthly_Value>3</Monthly_Value>
<Previous_Value>1</Previous_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>6</Period>
<Date>2021-09-30</Date>
<Metric>in</Metric>
<Monthly_Value>2</Monthly_Value>
<Previous_Value>3</Previous_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>7</Period>
<Date>2021-10-31</Date>
<Metric>in</Metric>
<Monthly_Value>2</Monthly_Value>
<Previous_Value>2</Previous_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>8</Period>
<Date>2021-11-30</Date>
<Metric>in</Metric>
<Monthly_Value>1</Monthly_Value>
<Previous_Value>2</Previous_Value>
</flow>
</flows>
<flows>
<Year>2020-2021</Year>
<flow>
<Year>2020-2021</Year>
<Period>8</Period>
<Date>2020-11-30</Date>
<Metric>out</Metric>
<Monthly_Value>4</Monthly_Value>
<Previous_Value>4</Previous_Value>
</flow>
<flow>
<Year>2020-2021</Year>
<Period>9</Period>
<Date>2020-12-31</Date>
<Metric>out</Metric>
<Monthly_Value>2</Monthly_Value>
<Previous_Value>4</Previous_Value>
</flow>
<flow>
<Year>2020-2021</Year>
<Period>10</Period>
<Date>2021-01-31</Date>
<Metric>out</Metric>
<Monthly_Value>1</Monthly_Value>
<Previous_Value>2</Previous_Value>
</flow>
<flow>
<Year>2020-2021</Year>
<Period>11</Period>
<Date>2021-02-28</Date>
<Metric>out</Metric>
<Monthly_Value>3</Monthly_Value>
<Previous_Value>1</Previous_Value>
</flow>
<flow>
<Year>2020-2021</Year>
<Period>12</Period>
<Date>2021-03-31</Date>
<Metric>out</Metric>
<Monthly_Value>1</Monthly_Value>
<Previous_Value>3</Previous_Value>
</flow>
</flows>
<flows>
<Year>2021-2022</Year>
<flow>
<Year>2021-2022</Year>
<Period>1</Period>
<Date>2021-04-30</Date>
<Metric>out</Metric>
<Monthly_Value>2</Monthly_Value>
<Previous_Value>2</Previous_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>2</Period>
<Date>2021-05-31</Date>
<Metric>out</Metric>
<Monthly_Value>1</Monthly_Value>
<Previous_Value>2</Previous_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>3</Period>
<Date>2021-06-30</Date>
<Metric>out</Metric>
<Monthly_Value>2</Monthly_Value>
<Previous_Value>1</Previous_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>4</Period>
<Date>2021-07-31</Date>
<Metric>out</Metric>
<Monthly_Value>1</Monthly_Value>
<Previous_Value>2</Previous_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>5</Period>
<Date>2021-08-31</Date>
<Metric>out</Metric>
<Monthly_Value>1</Monthly_Value>
<Previous_Value>1</Previous_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>6</Period>
<Date>2021-09-30</Date>
<Metric>out</Metric>
<Monthly_Value>2</Monthly_Value>
<Previous_Value>1</Previous_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>7</Period>
<Date>2021-10-31</Date>
<Metric>out</Metric>
<Monthly_Value>5</Monthly_Value>
<Previous_Value>2</Previous_Value>
</flow>
<flow>
<Year>2021-2022</Year>
<Period>8</Period>
<Date>2021-11-30</Date>
<Metric>out</Metric>
<Monthly_Value>1</Monthly_Value>
<Previous_Value>5</Previous_Value>
</flow>
</flows>
</income>
My Xquery:
for $metric in distinct-values($nodes//Metric)
for $y in distinct-values($nodes/flow[Metric eq $metric]/Year)
for $p in distinct-values($nodes/flow[Metric eq $metric and Year eq $y]/Period)
order by $p ascending
return
<income>{
for $node in $nodes
let $mv := $node/preceding-sibling::*
return
<Previous_Value>{$mv}</Previous_Value>
}
</income>
I get a sequence of 26 blank items:
<income><Previous_Value/></income>
How can I produce the correct output?

For your grouped items, you can't use XPath to look for preceding-sibling:: from the source XML. If you let a variable, such as the $sorted-flows below, of the flow elements ordered by Period, then you can obtain the Monthly_Value from the previous item in that sorted sequence.
Since the first item won't have a previous, it seemed that you wanted to use it's value as the Previous_Value. The logic below creates a sequence with the previous (if it exists), then the current value and uses head() to obtain the first item from that sequence.
<income>{
for $metric in distinct-values($nodes//Metric)
for $y in distinct-values($nodes/flow[Metric eq $metric]/Year)
let $sorted-flows :=
for $p in distinct-values($nodes/flow[Metric eq $metric and Year eq $y]/Period)
return
for $flow in $nodes/flow
where $flow[Metric eq $metric and Year eq $y and Period eq $p]
order by $flow/Period ascending
return $flow
return
<flows>{
element {"year"} {$y},
for $item at $i in $sorted-flows
return
<flow>{
$item/*,
<Previous_Value>{
(: either the previous Monthly_Value or the current for the first:)
($sorted-flows[$i - 1]/self::flow/Monthly_Value/data(), $item/Monthly_Value/data()) => head()
}
</Previous_Value>
}
</flow>
}
</flows>
}
</income>
You could also apply an XSLT and take advantage of xsl:for-each-group as an alternative solution:
let $xslt :=
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output indent="yes"/>
<xsl:template match="income">
<xsl:copy>
<flows>
<xsl:for-each-group select="flow" group-by="string-join((Year,Metric), '|')" >
<xsl:sort select="Metric" order="descending"/>
<flows>
<Year><xsl:value-of select="Year"/></Year>
<xsl:variable name="sorted-flows" as="element(flow)*">
<xsl:perform-sort select="current-group()">
<xsl:sort select="Period/number()" order="ascending"/>
</xsl:perform-sort>
</xsl:variable>
<xsl:for-each select="$sorted-flows">
<xsl:variable name="current-position" select="position()"/>
<xsl:copy>
<xsl:copy-of select="*"/>
<Previous_Value>
<xsl:value-of select="(($sorted-flows[$current-position - 1], .))[1]/Monthly_Value"/>
</Previous_Value>
</xsl:copy>
</xsl:for-each>
</flows>
</xsl:for-each-group>
</flows>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
return
xdmp:xslt-eval($xslt, $nodes)

I'm not really sure I understand the logic of your expected output, but something along these lines should get you close enough:
declare context item := document {
[your xml input]};
let $yrs :=distinct-values(
//flow/Year
),
$metrics := distinct-values(
//flow//Metric
)
return
for $yr in $yrs,
$met in $metrics
return
<income>{
<flows>{
<Metric>{
$met
}</Metric>,
<Year>{
(
$yr, '
',
for $fl in //flow[./Year=$yr][./Metric=$met]
let $pmv := $fl/preceding-sibling::flow[./Year=$yr][./Metric=$met][1]/Monthly_Value/text()
return <flow>{
$fl/(
Date,Period,Monthly_Value,
<Previous_Value>{
$pmv
}</Previous_Value>
)
}</flow>
)
}
</Year>
}</flows>
}</income>

Related

camel cxf consume service

I have a very simple Soap service with a String parameter and returns a String.
With Maven I've generated the corresponding classes from the WSDL.
I imported the wsdl into SOAP-UI and I made a mock.
I started the mock and I made a test case which sends and receives the response correctly.
I created a junit test with a camel route
and that's where it comes problems.
I can't build the url that would allow me to invoke my mock
I first simply put "cxf://http://localhost:8088/mockws_traca?DefaultOperationName=MajTracaDMI&wsdlURL=ws_traca.wsdl"
without success.
I added the service class
"&serviceClass="+WsTraca.class.getName()
which causes an invalid service error {http://localhost/ws_traca/wsdl/}WsTraca
after debug step by step I found the name of the generated service that I added
"&serviceName={http://localhost/ws_traca/wsdl/}ws_traca"
he made the same mistake with the type of port
I did not find a parameter to specify the type of port so I added its name
"&portName={http://localhost/ws_traca/wsdl/}ws_tracaSoapPort"
My routeBuilder
protected final RouteBuilder createRouteBuilder() throws Exception{
return new RouteBuilder() {
#Override
public void configure() throws Exception{
from("direct:start")
.setHeader(CxfConstants.OPERATION_NAME, constant("MajTracaDMI"))
.to("cxf://http://localhost:8088/mockws_traca"
+ "?serviceClass="+WsTraca.class.getName()
+ "&portName={http://localhost/ws_traca/wsdl/}ws_tracaSoapPort"
+ "&serviceName={http://localhost/ws_traca/wsdl/}ws_traca"
+ "&wsdlURL=ws_traca.wsdl"
);
}
};
}
the wsdl :
<?xml version='1.0' encoding='UTF-8' ?>
<!-- Generated 05/15/19 by Microsoft SOAP Toolkit WSDL File Generator, Version 3.00.1325.0 -->
<definitions
name='ws_traca'
targetNamespace='http://localhost/ws_traca/wsdl/'
xmlns:wsdlns='http://localhost/ws_traca/wsdl/'
xmlns:typens='http://localhost/ws_traca/type/'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:stk='http://schemas.microsoft.com/soap-toolkit/wsdl-extension'
xmlns:dime='http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/'
xmlns:ref='http://schemas.xmlsoap.org/ws/2002/04/reference/'
xmlns:content='http://schemas.xmlsoap.org/ws/2002/04/content-type/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
xmlns='http://schemas.xmlsoap.org/wsdl/'>
<types>
<schema
targetNamespace='http://localhost/ws_traca/type/'
xmlns='http://www.w3.org/2001/XMLSchema'
xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
elementFormDefault='qualified'>
<import namespace='http://schemas.xmlsoap.org/soap/encoding/'/>
<import namespace='http://schemas.xmlsoap.org/wsdl/'/>
<import namespace='http://schemas.xmlsoap.org/ws/2002/04/reference/'/>
<import namespace='http://schemas.xmlsoap.org/ws/2002/04/content-type/'/>
</schema>
</types>
<message name='ws_traca.MajTracaDMI'>
<part name='c_xml' type='xsd:string'/>
</message>
<message name='ws_traca.MajTracaDMIResponse'>
<part name='Result' type='xsd:string'/>
</message>
<message name='ws_traca.GetTracaDMI'>
<part name='c_xml' type='xsd:string'/>
</message>
<message name='ws_traca.GetTracaDMIResponse'>
<part name='Result' type='xsd:string'/>
</message>
<message name='ws_traca.Ping'>
<part name='c_chaine' type='xsd:string'/>
</message>
<message name='ws_traca.PingResponse'>
<part name='Result' type='xsd:string'/>
</message>
<message name='ws_traca.InfoDll'>
<part name='cXml' type='xsd:string'/>
</message>
<message name='ws_traca.InfoDllResponse'>
<part name='Result' type='xsd:string'/>
</message>
<portType name='ws_tracaSoapPort'>
<operation name='MajTracaDMI' parameterOrder='c_xml'>
<input message='wsdlns:ws_traca.MajTracaDMI'/>
<output message='wsdlns:ws_traca.MajTracaDMIResponse'/>
</operation>
<operation name='GetTracaDMI' parameterOrder='c_xml'>
<input message='wsdlns:ws_traca.GetTracaDMI'/>
<output message='wsdlns:ws_traca.GetTracaDMIResponse'/>
</operation>
<operation name='Ping' parameterOrder='c_chaine'>
<input message='wsdlns:ws_traca.Ping'/>
<output message='wsdlns:ws_traca.PingResponse'/>
</operation>
<operation name='InfoDll' parameterOrder='cXml'>
<input message='wsdlns:ws_traca.InfoDll'/>
<output message='wsdlns:ws_traca.InfoDllResponse'/>
</operation>
</portType>
<binding name='ws_tracaSoapBinding' type='wsdlns:ws_tracaSoapPort' >
<stk:binding preferredEncoding='UTF-8'/>
<soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/>
<operation name='MajTracaDMI'>
<soap:operation soapAction='http://localhost/ws_traca/action/ws_traca.MajTracaDMI'/>
<input>
<soap:body
namespace='http://localhost/ws_traca/message/'
parts='c_xml'/>
</input>
<output>
<soap:body
namespace='http://localhost/ws_traca/message/'
parts='Result'/>
</output>
</operation>
<operation name='GetTracaDMI'>
<soap:operation soapAction='http://localhost/ws_traca/action/ws_traca.GetTracaDMI'/>
<input>
<soap:body
namespace='http://localhost/ws_traca/message/'
parts='c_xml'/>
</input>
<output>
<soap:body
namespace='http://localhost/ws_traca/message/'
parts='Result'/>
</output>
</operation>
<operation name='Ping'>
<soap:operation soapAction='http://localhost/ws_traca/action/ws_traca.Ping'/>
<input>
<soap:body
namespace='http://localhost/ws_traca/message/'
parts='c_chaine'/>
</input>
<output>
<soap:body
namespace='http://localhost/ws_traca/message/'
parts='Result'/>
</output>
</operation>
<operation name='InfoDll'>
<soap:operation soapAction='http://localhost/ws_traca/action/ws_traca.InfoDll'/>
<input>
<soap:body
namespace='http://localhost/ws_traca/message/'
parts='cXml'/>
</input>
<output>
<soap:body
namespace='http://localhost/ws_traca/message/'
parts='Result'/>
</output>
</operation>
</binding>
<service name='ws_traca' >
<port name='ws_tracaSoapPort' binding='wsdlns:ws_tracaSoapBinding' >
<soap:address location='http://localhost/ws_trunk/ws_traca.WSDL'/>
</port>
</service>
</definitions>
I've now an error on WsTraca that not an interface
org.apache.camel.FailedToCreateProducerException: Failed to create Producer for endpoint: Endpoint[cxf://http://SAP5223897:8088/mockws_traca?portName=%7Bhttp%3A%2F%2Flocalhost%2Fws_traca%2Fwsdl%2F%7Dws_tracaSoapPort&serviceClass=localhost.ws_traca.wsdl.WsTraca&serviceName=%7Bhttp%3A%2F%2Flocalhost%2Fws_traca%2Fwsdl%2F%7Dws_traca&wsdlURL=ws_traca.wsdl]. Reason: java.lang.IllegalArgumentException: localhost.ws_traca.wsdl.WsTraca is not an interface
at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:380)
at org.apache.camel.impl.ProducerCache.acquireProducer(ProducerCache.java:107)
at org.apache.camel.impl.ProducerCache.startProducer(ProducerCache.java:138)
at org.apache.camel.processor.SendProcessor.doStart(SendProcessor.java:163)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:56)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:70)
at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:77)
at org.apache.camel.processor.interceptor.TraceInterceptor.doStart(TraceInterceptor.java:444)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:56)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:70)
at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:77)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:56)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:70)
at org.apache.camel.processor.RedeliveryErrorHandler.doStart(RedeliveryErrorHandler.java:982)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:56)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:70)
at org.apache.camel.processor.DefaultChannel.doStart(DefaultChannel.java:149)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:56)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:82)
at org.apache.camel.processor.MulticastProcessor.doStart(MulticastProcessor.java:920)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:56)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:70)
at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:77)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:56)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:70)
at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:77)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:56)
at org.apache.camel.impl.RouteService.startChildService(RouteService.java:245)
at org.apache.camel.impl.RouteService.warmUp(RouteService.java:142)
at org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:1843)
at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:1771)
at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:1556)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1448)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1338)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1316)
at org.apache.camel.test.junit4.CamelTestSupport.startCamelContext(CamelTestSupport.java:344)
at org.apache.camel.test.junit4.CamelTestSupport.doSetUp(CamelTestSupport.java:228)
at org.apache.camel.test.junit4.CamelTestSupport.setUp(CamelTestSupport.java:167)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:47)
at org.junit.rules.RunRules.evaluate(RunRules.java:18)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:542)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
Caused by: java.lang.IllegalArgumentException: localhost.ws_traca.wsdl.WsTraca is not an interface
at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:470)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:690)
at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:171)
at org.apache.camel.component.cxf.CxfEndpoint.createClient(CxfEndpoint.java:455)
at org.apache.camel.component.cxf.CxfProducer.<init>(CxfProducer.java:71)
at org.apache.camel.component.cxf.CxfEndpoint.createProducer(CxfEndpoint.java:153)
at org.apache.camel.impl.InterceptSendToEndpoint.createProducer(InterceptSendToEndpoint.java:93)
at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:376)
... 83 more

Message payload is of type: BufferInputStream on Mule

I'm starting with Mule, and I've tried to execute some examples from their page, although almost always I'm getting the same error: "Message payload is of type: BufferInputStream", so I don't know if something is wrong with my flow. This is my XML
<mule xmlns:json="http://www.mulesoft.org/schema/mule/json"
xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:db="http://www.mulesoft.org/schema/mule/db" 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" version="CE-3.6.1"
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/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd">
<db:template-query name="insert_into_current" doc:name="Template Query">
<db:parameterized-query><![CDATA[INSERT INTO current("name", "date", "bookvalue") VALUES(:name,:date,:bookvalue);]]></db:parameterized-query>
<db:in-param name="name" defaultValue="#[xpath('//Name').text]"/>
<db:in-param name="date" type="DATE" defaultValue="#[xpath('//LastTradeDate').text]"/>
<db:in-param name="bookvalue" defaultValue="#[xpath('//BookValue').text])"/>
</db:template-query>
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration"/>
<http:request-config name="HTTP_Request_Configuration" host="query.yahooapis.com" basePath="v1/public/yql" doc:name="HTTP Request Configuration" port="80"/>
<db:mysql-config name="MySQL_Configuration" host="xxxxxx" port="3306" user="" password="xxxx" database="xxxx" doc:name="MySQL Configuration"/>
<flow name="financeapiFlow1" >
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<http:request config-ref="HTTP_Request_Configuration" path="/" method="GET" followRedirects="true" doc:name="HTTP">
<http:request-builder>
<http:query-param paramName="q" value="#[message.inboundProperties.'http.query.params'.q]"/>
<http:query-param paramName="env" value="#[message.inboundProperties.'http.query.params'.env]"/>
<http:query-param paramName="format" value="#[message.inboundProperties.'http.query.params'.format]"/>
</http:request-builder>
</http:request>
<logger message=""### VALUES "+#[message.inboundProperties.'http.query.params'.q]+" - "+#[message.inboundProperties.'http.query.params'.env]+" - "+#[message.inboundProperties.'http.query.params'.format]" level="INFO" doc:name="Logger"/>
<json:json-to-object-transformer returnClass="java.util.Map" doc:name="JSON to Object"/>
<db:insert config-ref="MySQL_Configuration" doc:name="Database">
<db:dynamic-query><![CDATA[INSERT INTO MULE("symbol", "lastTradeDate", "bookvalue") VALUES('#[message.payload.query.results.quote.symbol]','#[message.payload.query.results.quote.LastTradeDate]','#[message.payload.query.results.quote.BookValue]');]]></db:dynamic-query>
</db:insert>
</flow>
This is my stack trace:
Exception stack is:
1. null (java.lang.NullPointerException)
org.mule.mvel2.optimizers.impl.refl.nodes.MapAccessor:42 (null)
2. cannot invoke getter: getInboundProperties (see trace) (java.lang.RuntimeException)
org.mule.mvel2.optimizers.impl.refl.nodes.GetterAccessor:70 (null)
3. Execution of the expression "message.inboundProperties.'http.query.params'.q" failed. (org.mule.api.expression.ExpressionRuntimeException)
org.mule.el.mvel.MVELExpressionLanguage:202 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/expression/ExpressionRuntimeException.html)
4. Execution of the expression "message.inboundProperties.'http.query.params'.q" failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: BufferInputStream (org.mule.api.MessagingException)
org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor:32 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.NullPointerException
at org.mule.mvel2.optimizers.impl.refl.nodes.MapAccessor.getValue(MapAccessor.java:42)
at org.mule.mvel2.optimizers.impl.refl.nodes.MapAccessor.getValue(MapAccessor.java:39)
at org.mule.mvel2.optimizers.impl.refl.nodes.GetterAccessor.getValue(GetterAccessor.java:40)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
Thanks!
The problem is that once you get to the request, the inboundProperties from the listener are lost so the expression on the following logger fails. I recommend saving those properties to variables or moving up the logger if what you want is just to have visibility on what the HTTP request is going to look like.

java.lang.Exception: No such operation: login j

I'm trying to invoke sfdc login webservice from mule. I generated classes using apache cxxf wsdl2java on partner wsdl. I tried all possible ways of sending the input,but still continue to get the "java.lang.Exception: No such operation: login" error
Following is my flow:
<mule....>
<cxf:configuration name="CXF_Configuration" enableMuleSoapHeaders="true" initializeStaticBusInstance="true" doc:name="CXF Configuration"/>
<flow name="mainFlow1" doc:name="mainFlow1">
<http:inbound-endpoint exchange-pattern="request-response" path="sfdclogin" host="localhost" port="8081" doc:name="HTTP"/>
<scripting:component doc:name="Groovy">
<scripting:script engine="Groovy"><![CDATA[import com.sforce.soap.partner.*;
ObjectFactory of= new ObjectFactory();
com.sforce.soap.partner.Login loginReq=new com.sforce.soap.partner.Login();
loginReq.setUsername("username");
loginReq.setPassword("password");
return loginReq;]]></scripting:script>
</scripting:component>
<cxf:jaxws-client operation="login" serviceClass="com.sforce.soap.partner.SforceService" doc:name="SOAP"/>
<https:outbound-endpoint address="https://test.salesforce.com/services/Soap/u/30.0" exchange-pattern="request-response" method="POST" doc:name="HTTPS"/>
</flow>
</mule>
Exception stack trace. As can be seen below, correct object of Login type is being passed to SOAP component.
Object after transform: com.sforce.soap.partner.Login#5d9683ed
The transformed object is of expected type. Type is: Login
********************************************************************************
Message : No such operation: login. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: Login
Type : org.mule.api.transport.DispatchException
Code : MULE_ERROR--2
Payload : com.sforce.soap.partner.Login#5d9683ed
JavaDoc : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html
********************************************************************************
Exception stack is:
1. No such operation: login (java.lang.Exception)
org.mule.module.cxf.CxfOutboundMessageProcessor:282 (null)
2. No such operation: login. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: Login (org.mule.api.transport.DispatchException)
org.mule.module.cxf.CxfOutboundMessageProcessor:150 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)
********************************************************************************
Root Exception stack trace:
java.lang.Exception: No such operation: login
at org.mule.module.cxf.CxfOutboundMessageProcessor.getOperation(CxfOutboundMessageProcessor.java:282)
at org.mule.module.cxf.CxfOutboundMessageProcessor.getOperation(CxfOutboundMessageProcessor.java:363)
WSDL:
<!-- Login Message Types -->
<element name="login">
<complexType>
<sequence>
<element name="username" type="xsd:string"/>
<element name="password" type="xsd:string"/>
</sequence>
</complexType>
</element>
<message name="loginRequest">
<part element="tns:login" name="parameters"/>
</message>
<!-- Soap PortType -->
<portType name="Soap">
<operation name="login">
<documentation>Login to the Salesforce.com SOAP Api</documentation>
<input message="tns:loginRequest"/>
<output message="tns:loginResponse"/>
<fault message="tns:LoginFault" name="LoginFault"/>
<fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
<fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
</operation>
</portType>
<!-- Soap Binding -->
<binding name="SoapBinding" type="tns:Soap">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="login">
<soap:operation soapAction=""/>
<input>
<soap:header use="literal" message="tns:Header" part="LoginScopeHeader"/>
<soap:header use="literal" message="tns:Header" part="CallOptions"/>
<soap:body parts="parameters" use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
<fault name="LoginFault">
<soap:fault name="LoginFault" use="literal"/>
</fault>
<fault name="UnexpectedErrorFault">
<soap:fault name="UnexpectedErrorFault" use="literal"/>
</fault>
<fault name="InvalidIdFault">
<soap:fault name="InvalidIdFault" use="literal"/>
</fault>
</operation>
</binding>
<!-- Soap Service Endpoint -->
<service name="SforceService">
<documentation>Sforce SOAP API</documentation>
<port binding="tns:SoapBinding" name="Soap">
<soap:address location="https://test.salesforce.com/services/Soap/u/30.0"/>
</port>
</service>

use load balancing with wso2esb

I use From Wso2 esb And Load Balancing Concept with sevices, but i have an error this is my code:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="MultiAdd" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<log level="full"/>
<log level="full" category="FATAL"/>
<property xmlns:tem="http://tempuri.org/" name="AParam" expression="//tem:SumSerVise/tem:a" scope="default" type="INTEGER"/>
<property xmlns:tem="http://tempuri.org/" name="BParam" expression="//tem:SumSerVise/tem:b" scope="default" type="INTEGER"/>
<log level="custom">
<property name="AParam" expression="$ctx:AParam"/>
<property name="BParam" expression="$ctx:BParam"/>
</log>
<payloadFactory>
<format>
<p:SumSerVise xmlns:p="http://tempuri.org/">
<!--Exactly 1 occurrence-->
<s:a xmlns:s="http://tempuri.org/">$1</s:a>
<!--Exactly 1 occurrence-->
<s:b xmlns:s="http://tempuri.org/">$2</s:b>
</p:SumSerVise>
</format>
<args>
<arg expression="$ctx:AParam"/>
<arg expression="$ctx:BParam"/>
</args>
</payloadFactory>
<log level="full"/>
<send receive="SeqOne">
<endpoint>
<address uri="http://D-N-PC-12071:8280/services/Add"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<log level="full"/>
<send/>
</outSequence>
</target>
<publishWSDL>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://tempuri.org/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
<s:element name="SumSerVise">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="a" type="s:int"/>
<s:element minOccurs="1" maxOccurs="1" name="b" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="SumSerViseResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="SumSerViseResult" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="SumSerViseSoapIn">
<wsdl:part name="parameters" element="tns:SumSerVise"/>
</wsdl:message>
<wsdl:message name="SumSerViseSoapOut">
<wsdl:part name="parameters" element="tns:SumSerViseResponse"/>
</wsdl:message>
<wsdl:portType name="ServiceSoap">
<wsdl:operation name="SumSerVise">
<wsdl:input message="tns:SumSerViseSoapIn"/>
<wsdl:output message="tns:SumSerViseSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ServiceSoap" type="tns:ServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="SumSerVise">
<soap:operation soapAction="http://tempuri.org/SumSerVise" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="ServiceSoap12" type="tns:ServiceSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="SumSerVise">
<soap12:operation soapAction="http://tempuri.org/SumSerVise" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Service">
<wsdl:port name="ServiceSoap" binding="tns:ServiceSoap">
<soap:address location="http://localhost/SumServices/Service.asmx"/>
</wsdl:port>
<wsdl:port name="ServiceSoap12" binding="tns:ServiceSoap12">
<soap12:address location="http://localhost/SumServices/Service.asmx"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
</publishWSDL>
<description></description>
</proxy>
and this is my sequence:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="SeqOne">
<log level="full"/>
<property xmlns:ns="http://org.apache.synapse/xsd" xmlns:m0="http://tempuri.org/" name="CParam" expression="//m0:SumSerViseResponse/m0:SumSerViseResult" scope="default" type="INTEGER"/>
<log level="custom">
<property xmlns:ns="http://org.apache.synapse/xsd" name="CParam" expression="$ctx:CParam"/>
</log>
<payloadFactory>
<format>
<p:MultiService xmlns:p="http://tempuri.org/">
<!--Exactly 1 occurrence-->
<s:z xmlns:s="http://tempuri.org/">$1</s:z>
</p:MultiService>
</format>
<args>
<arg xmlns:ns="http://org.apache.synapse/xsd" expression="$ctx:CParam"/>
</args>
</payloadFactory>
<log level="full"/>
<send>
<endpoint>
<loadbalance algorithm="org.apache.synapse.endpoints.algorithms.RoundRobin">
<endpoint name="mt">
<address uri="http://D-N-PC-12071:8280/services/MultiService/MultiService"/>
</endpoint>
<endpoint name="KR">
<address uri="http://D-N-PC-12071:8280/services/Multi/MultiService"/>
</endpoint>
</loadbalance>
</endpoint>
</send>
</sequence>
when use load balancing one of services return value 0 and other return correct value
i found my problem was in define endpoint kr and mt that wasnt correct
my parameters in multiservice should be compatible with source
parameters in mt was named "z"
<endpoint name="mt">
<address uri="http://D-N-PC-12071:8280/services/MultiService/MultiService"/>
</endpoint>
but parameters in kr was named "a"
<endpoint name="KR">
<address uri="http://D-N-PC-12071:8280/services/Multi/MultiService"/>
</endpoint>

generate soap xml from wsdl proxy class

Questions:I am not sure if I need a custombinding or wshttpsbinding.
This is my web.config
<bindings>
<!--<wsHttpBinding>
<binding name="EBinding">
<security mode="Transport" authenticationMode="SecureConversation" requireSecurityContextCancellation="true">
<message clientCredentialType="IssuedToken"/>
--><!--Specifies the character encoding and message versioning used for text-based XML messages.--><!--
<textMessageEncoding messageVersion="Soap11"/>
<httpTransport/>
</security>
</binding>
</wsHttpBinding>-->
<customBinding>
<binding name="MHService_MHSPort">
<!-- WsdlImporter encountered unrecognized policy assertions in ServiceDescription 'http://org/emedny/mhs/': -->
<!-- <wsdl:binding name='MHS'> -->
<!-- <dpe:summary xmlns:dpe="http://www.datapower.com/extensions">..</dpe:summary> -->
<!-- <sp:SupportingTokens xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">..</sp:SupportingTokens> -->
<security mode="Transport" authenticationMode="SecureConversation" requireSecurityContextCancellation="true">
<message clientCredentialType="IssuedToken"/>
<!--Specifies the character encoding and message versioning used for text-based XML messages.-->
<textMessageEncoding messageVersion="Soap11"/>
</security>
<!--Specifies the character encoding and message versioning used for text-based XML messages.-->
<textMessageEncoding messageVersion="Soap11"/>
<httpTransport/>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://12.23.28.113:9047/MHService"
binding="MHService_MHSPort" bindingConfiguration="MHService_MHSPort" contract="ProxyGeneration.MHS" name="MHSPort" />
</client>
<behaviors>
<endpointBehaviors>
<behavior name="CustomBehaviorConfiguration">
<clientCredentials>
<clientCertificate findValue="LMWARD" x509FindType="FindBySubjectName" storeLocation="CurrentUser" storeName="My"/>
<serviceCertificate>
<authentication revocationMode="NoCheck" certificateValidationMode="None"/>
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
This is my wsdl
<wsdl:definitions xmlns:wsp200607="http://www.w3.org/2006/07/ws-policy" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:ns0="http://org/emedny/mhs/" xmlns:wsp200409="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap11="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://org/emedny/mhs/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsp:Policy wsu:Id="policy0" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsp:ExactlyOne>
<wsp:All>
<sp:AsymmetricBinding xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<wsp:Policy>
<wsp:ExactlyOne>
<wsp:All>
<sp:InitiatorToken>
<wsp:Policy>
<wsp:ExactlyOne>
<wsp:All>
<sp:X509Token>
<wsp:Policy>
<wsp:ExactlyOne>
<wsp:All>
<sp:WssX509V3Token11 />
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</sp:X509Token>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</sp:InitiatorToken>
<sp:RecipientToken>
<wsp:Policy>
<wsp:ExactlyOne>
<wsp:All>
<sp:X509Token>
<wsp:Policy>
<wsp:ExactlyOne>
<wsp:All>
<sp:WssX509V3Token11 />
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</sp:X509Token>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</sp:RecipientToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<wsp:ExactlyOne>
<wsp:All>
<sp:TripleDesRsa15 />
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</sp:AlgorithmSuite>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</sp:AsymmetricBinding>
<sp:SignedParts xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<sp:Body />
</sp:SignedParts>
<sp:EncryptedParts xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<sp:Body />
</sp:EncryptedParts>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsp:Policy wsu:Id="policy1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsp:ExactlyOne>
<wsp:All>
<dpe:summary xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" xmlns:dpe="http://www.datapower.com/extensions">
<dppolicy:domain xmlns:dppolicy="http://www.datapower.com/policy">
http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702
</dppolicy:domain>
<description>
Implements WS Security Policy 1.2 - UsernameToken 1.0 support
</description>
</dpe:summary>
<sp:SupportingTokens xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<wsp:Policy>
<wsp:ExactlyOne>
<wsp:All>
<sp:UsernameToken sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient">
<wsp:Policy>
<wsp:ExactlyOne>
<wsp:All>
<sp:WssUsernameToken10 />
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</sp:UsernameToken>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</sp:SupportingTokens>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsdl:types xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:schema>
<xsd:import schemaLocation="MHService.xsd1.xsd" namespace="http://org/emedny/mhs/" />
</xsd:schema>
</wsdl:types>
<wsdl:message name="getCCDResponse">
<wsdl:part xmlns:xsns="http://org/emedny/mhs/" name="parameters" element="xsns:getCCDResponse" />
</wsdl:message>
<wsdl:message name="getEligibilityRequest">
<wsdl:part xmlns:xsns="http://org/emedny/mhs/" name="parameters" element="xsns:getEligibility" />
</wsdl:message>
<wsdl:message name="getEligibilityResponse">
<wsdl:part xmlns:xsns="http://org/emedny/mhs/" name="parameters" element="xsns:getEligibilityResponse" />
</wsdl:message>
<wsdl:message name="getNCPDPHistoryRequest">
<wsdl:part xmlns:xsns="http://org/emedny/mhs/" name="parameters" element="xsns:getNCPDPHistory" />
</wsdl:message>
<wsdl:message name="getNCPDPHistoryResponse">
<wsdl:part xmlns:xsns="http://org/emedny/mhs/" name="parameters" element="xsns:getNCPDPHistoryResponse" />
</wsdl:message>
<wsdl:message name="getPDQRequest">
<wsdl:part xmlns:xsns="http://org/emedny/mhs/" name="parameters" element="xsns:getPDQRequest" />
</wsdl:message>
<wsdl:message name="MHSFault">
<wsdl:part xmlns:xsns="http://org/emedny/mhs/" name="parameters" element="xsns:Fault" />
</wsdl:message>
<wsdl:portType name="MHS">
<wsdl:operation name="getCCD">
<wsdl:input name="getPDQRequest" message="ns0:getPDQRequest" />
<wsdl:output name="getCCDResponse" message="ns0:getCCDResponse" />
<wsdl:fault name="MHSFault" message="ns0:MHSFault" />
</wsdl:operation>
<wsdl:operation name="getEligibility">
<wsdl:input name="getEligibilityRequest" message="ns0:getEligibilityRequest" />
<wsdl:output name="getEligibilityResponse" message="ns0:getEligibilityResponse" />
<wsdl:fault name="MHSFault" message="ns0:MHSFault" />
</wsdl:operation>
<wsdl:operation name="getNCPDPHistory">
<wsdl:input name="getNCPDPHistoryRequest" message="ns0:getNCPDPHistoryRequest" />
<wsdl:output name="getNCPDPHistoryResponse" message="ns0:getNCPDPHistoryResponse" />
<wsdl:fault name="MHSFault" message="ns0:MHSFault" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="MHS" type="ns0:MHS">
<soap11:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="getCCD">
<soap11:operation soapAction="" style="document" />
<wsdl:input name="getPDQRequest">
<soap11:body use="literal" />
</wsdl:input>
<wsdl:output name="getCCDResponse">
<soap11:body use="literal" />
</wsdl:output>
<wsdl:fault name="MHSFault">
<soap11:fault use="literal" name="MHSFault" namespace="" />
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="getEligibility">
<soap11:operation soapAction="" style="document" />
I dont have any kind of SOAp headers to use in my proxyclass. I am missing security headers for ws-security for web.config.
This is how the sample soap request header looks like
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mhs="http://org/emedny/mhs/" xmlns:urn="urn:hl7-org:v3">
<soapenv:Header>
<wsse:Security soap:mustUnderstand="1" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:BinarySecurityToken ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SecurityToken-e00c8062-83d2-4f04-88fc-996218e7bb3d">MIICeDCC....(eMedNY signed user MLS cert).......</wsse:BinarySecurityToken>
<wsse:BinarySecurityToken ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SecurityToken-c0cc2cd4-cb77-4fa5-abfa-bd485afd1685">MIIDFj.....( eMedNY MLS web-service end-point public cert)........</wsse:BinarySecurityToken>
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SecurityToken-970e9a80-00cc-4c86-8ec4-3ba16e029a5b">
<wsse:Username>....your_username.....</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">.....your_plaintext_password....</wsse:Password>
<wsse:Nonce>KNyu6MsXCkTg4DDyvwvEiw==</wsse:Nonce>
<wsu:Created>2010-09-15T18:00:30Z</wsu:Created>
</wsse:UsernameToken>
<xenc:EncryptedKey xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
<xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"/>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<wsse:SecurityTokenReference>
<wsse:Reference URI="#SecurityToken-c0cc2cd4-cb77-4fa5-abfa-bd485afd1685" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>
</wsse:SecurityTokenReference>
</KeyInfo>
<xenc:CipherData>
<xenc:CipherValue>gpBAWt91pdwhKva............</xenc:CipherValue>
</xenc:CipherData>
<xenc:ReferenceList>
<xenc:DataReference URI="#Enc-0641b860-b16d-4941-91c0-d60bece67794"/>
</xenc:ReferenceList>
</xenc:EncryptedKey>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
I am using wcf to do this.How do I actually generate the soap xml. I don't want to be hard coding all this.. Although I started to do this.
` soapXML = "http://schemas.xmlsoap.org/soap/envelope/\" xmlns:mhs=\"http://org/emedny/mhs/\" xmlns:urn=\"urn:hl7-org:v3\" >";
soapXML += "\n";
// Add security block for X.509 certificate
soapXML = "<wsse:Security soap:mustUnderstand=\"1\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">";
soapXML += "<wsse:BinarySecurityToken ValueType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3";
soapXML += "EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
`
Even if I do how would I generate these security and binary tokens. This request uses ws-security..I am doing my research and reading about it to the best of my understanding.
Thank you
user