WSO2ESB Proxy - Payload mediator auto population - java

I want to populate payload mediator with the response from a first service and this payload is going to be sent to another service. I used context expression and everything seems correct. But payload mediator is not getting populated. When the message built to send to the second service, payload remains blank. I used ctx path expression shown below to populate.
Here is the proxy service configuration,
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="CreditProxy"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<log level="full">
<property name="sequence" value="inSequence - request for CreditProxy"/>
</log>
<property xmlns:sam="http://samples.esb.wso2.org"
name="ORG_ID"
expression="//sam:credit/sam:id"/>
<property xmlns:sam="http://samples.esb.wso2.org"
name="ORG_AMOUNT"
expression="//sam:credit/sam:amount"/>
<enrich>
<source type="inline" clone="true">
<sam:get xmlns:sam="http://samples.esb.wso2.org">
<sam:id>?</sam:id>
</sam:get>
</source>
<target type="body"/>
</enrich>
<enrich>
<source type="property" clone="true" property="ORG_ID"/>
<target xmlns:sam="http://samples.esb.wso2.org" xpath="//sam:get/sam:id"/>
</enrich>
<log level="full">
<property name="sequence" value="inSequence - request for PersonInfoService"/>
</log>
<property name="STATE" value="PERSON_INFO_REQUEST"/>
<send>
<endpoint>
<address uri="http://127.0.0.1:9764/services/PersonInfoService/"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<log level="full"/>
<property xmlns:ns="http://samples.esb.wso2.org"
xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"
xmlns:ax23="http://samples.esb.wso2.org/xsd"
name="address"
expression="/soapenv:Envelope/soapenv:Body/ns:getResponse/ns:return/ax23:address"
scope="default"
type="STRING"/>
<property xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"
xmlns:ns="http://samples.esb.wso2.org"
xmlns:ax23="http://samples.esb.wso2.org/xsd"
name="id"
expression="/soapenv:Envelope/soapenv:Body/ns:getResponse/ns:return/ax23:id"
scope="default"
type="STRING"/>
<property xmlns:ns="http://samples.esb.wso2.org"
xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"
xmlns:ax23="http://samples.esb.wso2.org/xsd"
name="name"
expression="/soapenv:Envelope/soapenv:Body/ns:getResponse/ns:return/ax23:name"
scope="default"
type="STRING"/>
<payloadFactory media-type="xml">
<format>
<p:credit xmlns:p="http://samples.esb.wso2.org"><!--0 to 1 occurrence--><ax25:info xmlns:ax25="http://samples.esb.wso2.org"><!--0 to 1 occurrence--><xs:amount xmlns:xs="http://samples.esb.wso2.org/xsd">?</xs:amount>
<!--0 to 1 occurrence--><ax25:personInfo xmlns:ax25="http://samples.esb.wso2.org/xsd"><!--0 to 1 occurrence--><xs:address xmlns:xs="http://samples.esb.wso2.org/xsd">$1</xs:address>
<!--0 to 1 occurrence--><xs:id xmlns:xs="http://samples.esb.wso2.org/xsd">$2</xs:id>
<!--0 to 1 occurrence--><xs:name xmlns:xs="http://samples.esb.wso2.org/xsd">$3</xs:name>
</ax25:personInfo>
</ax25:info>
</p:credit>
</format>
<args>
<arg evaluator="xml" expression="$ctx:address"/>
<arg evaluator="xml" expression="$ctx:id"/>
<arg evaluator="xml" expression="$ctx:name"/>
</args>
</payloadFactory>
<send buildmessage="true">
<endpoint>
<address uri="http://127.0.0.1:9764/services/CreditService/"/>
</endpoint>
</send>
</outSequence>
<endpoint>
<address uri="http://127.0.0.1:9764/services/PersonInfoService/"/>
</endpoint>
</target>
<publishWSDL uri="file:./repository/samples/resources/proxy/CreditProxy.wsdl"/>
<description/>
</proxy>
What can be the reason for this?

Related

Change value in XML file via Android Java

I want to change the "value" and "defaultValue" of the "drop" that contains "a33"
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<settings version="-1">
<setting id="1" name="a1" value="VAL555" drop="a12" defaultValue="VAL555" default="false" tag="null" />
<setting id="2" name="a2" value="VAL555" drop="a22" defaultValue="VAL555" default="false" tag="null" />
<setting id="3" name="a3" value="VAL555 <== I WANT TO CHANGE THIS" drop="a33" defaultValue="VAL555 <== I WANT TO CHANGE THIS" default="false" tag="null" />
<setting id="4" name="a4" value="VAL555" drop="a44" defaultValue="VAL555" default="false" tag="null" />
<setting id="5" name="a5" value="VAL555" drop="a55" defaultValue="VAL555" default="false" tag="null" />
</settings>
I want to do this for an app in Android Java
Currently, I can't go anywhere.
I have no idea where to start from, or where to look for.

Authenticating SOAP service using certificate encodedValue in MULE ESB

I'm provided with a wsdl and have to access certain service (TestMessage) using the authentication credentials provided (username : test-Ser, password: XXXX). The wsdl file was generated from the given config file in C#.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="PProxyEndpoint">
<security>
<message clientCredentialType="UserName" establishSecurityContext="false" />
</security>
</binding>
<binding name="PProxyEndpointSvcCertSpecified">
<security>
<message clientCredentialType="UserName" negotiateServiceCredential="false"
establishSecurityContext="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://p-cer.test.ca/PService.svc"
binding="wsHttpBinding" bindingConfiguration="PProxyEndpoint"
contract="IPService" name="PProxyEndpoint">
<identity>
<certificate encodedValue="XXXXXXXXXXXXXXXXXX............" />
</identity>
</endpoint>
<endpoint address="http://p-cer.test.ca/PService.svc/SvcCertSpecified"
binding="wsHttpBinding" bindingConfiguration="PProxyEndpointSvcCertSpecified"
contract="IPService" name="PProxyEndpointSvcCertSpecified">
<identity>
<certificate encodedValue="XXXXXXXXXXXXXXXXXX............" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
The authentication code is in C# as below:
private static TestClient AuthUser()
{
TestClient client = new TestClient();
client.ClientCredentials.UserName.UserName = “XXXX”;
client.ClientCredentials.UserName.Password = “XXXXX”;
return client;
}
using (TestClient test = AuthUser())
{
TestListRequestItemWrapper ttt = new TestListRequestItemWrapper();
ttt.RequestItems = new ListRequestItem[1];
ttt.RequestItems[0] = new ListRequestItem();
TestListResponseItemWrapper resp = test.TestList(ttt);
}
I have to do same such thing in java, And I'm unable to do so. Please help.
How can I authenticate SOAP service using certificate encoded value in JAVA?
My configuration.xml in Mule ESB is as follow
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" basePath="test" doc:name="HTTP Listener Configuration"/>
<spring:beans>
<spring:bean name="myPasswordCallback" class="com.org.message.PasswordCallback"/>
</spring:beans>
<spring:beans>
<spring:bean id="wss4jInConfiguration" name="Bean" class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
<spring:constructor-arg>
<spring:map>
<spring:entry key="action" value="UsernameToken "/>
<spring:entry key="passwordType" value="PasswordText"/>
<spring:entry key="user" value="vha-test.xml"/>
<spring:entry key="passwordCallbackRef" value-ref="myPasswordCallback">
</spring:entry>
</spring:map>
</spring:constructor-arg>
</spring:bean>
</spring:beans>
<http:listener-config name="HTTP_Listener_Configuration_3" host="0.0.0.0" port="8083" doc:name="HTTP Listener Configuration"/>
<ws:consumer-config name="Web_Service_Consumer" wsdlLocation="http://path.svc?wsdl" service="XService" port="XProxyEndpointSvcCertSpecified" serviceAddress="http://path.svc/SvcCertSpecified" doc:name="Web Service Consumer"/>
<flow name="testdemoFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<custom-transformer class="com.org.message.GetMessageExample" doc:name="Java"/>
<response>
<object-to-string-transformer doc:name="Object to String"/>
</response>
<cxf:jaxws-client serviceClass="com.org.IXmlService" doc:name="CXF" operation="GetMessageList" port="IXmlService" soapVersion="1.2">
<!-- <cxf:ws-security>
<cxf:ws-config>
<cxf:property key="action" value="UsernameToken"/>
<cxf:property key="user" value="uname"/>
<cxf:property key="passwordCallbackClass" value="com.org.message.PasswordCallback"/>
<cxf:property key="passwordType" value="PasswordText"/>
</cxf:ws-config>
</cxf:ws-security> -->
<cxf:inInterceptors>
<spring:bean class="org.apache.cxf.interceptor.LoggingInInterceptor" />
<spring:bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
<spring:constructor-arg>
<spring:map>
<spring:entry key="action" value="Signature" />
<spring:entry key="signaturePropFile" value="src/main/resources/ws-sign-security.properties" />
</spring:map>
</spring:constructor-arg>
</spring:bean>
</cxf:inInterceptors>
</cxf:jaxws-client>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
<message-properties-transformer doc:name="Message Properties">
<add-message-property key="Content-type" value="application/soap+xml"/>
<add-message-property key="charset" value="UTF-8"/>
</message-properties-transformer>
<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8084" method="POST" doc:name="HTTP"/>
</flow>
and below is another configuration.xml I've tried:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ws="http://www.mulesoft.org/schema/mule/ws" 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/ws http://www.mulesoft.org/schema/mule/ws/current/mule-ws.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" basePath="wsdl" doc:name="HTTP Listener Configuration"/>
<ws:consumer-config name="Web_Service_Consumer" wsdlLocation="http://patyh.svc?wsdl" service="XService" port="XProxyEndpoint" serviceAddress="http://path.svc" doc:name="Web Service Consumer">
<ws:security>
<ws:wss-username-token username="uname" password="password" passwordType="TEXT" addCreated="true" addNonce="true"/>
<ws:wss-timestamp expires="60000"/>
</ws:security>
</ws:consumer-config>
<flow name="wsdltestFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<ws:consumer config-ref="Web_Service_Consumer" operation="PingWithAuthorization" doc:name="Web Service Consumer"/>
<logger level="INFO" doc:name="Logger" message="req gen : #[payload]"/>
</flow>
</mule>
I'm still not able to authenticate with any of the XMl

Set value text field in Activiti Worflow (Alfresco Model)

I have a Workflow with 2 tasks, and first task has a model with a text field (wfRepromaq:ObsAnaliseCredito).
I want to show this field on my next task with value informed on my first task when i run workflow in the Alfresco Cummunity.
My Models:
1ª Task:
<type name="wfRepromaq:analisarCredito">
<title>Analisar Crédito</title>
<parent>wfRepromaq:iniciarFluxo</parent>
<properties>
<!-- Custom field-->
<property name="wfRepromaq:ObsAnaliseCredito">
<title>Observação Analise de Crédito</title>
<type>d:text</type>
<mandatory>true</mandatory>
</property>
<!-- End fied-->
</properties>
</type>
2ª Task:
<type name="wfRepromaq:analiseComercialPedido">
<title>Análise Pedido Gerência Comercial</title>
<parent>wfRepromaq:analisarCredito</parent>
<properties>
<property name="wfRepromaq:reviewOutcome3">
<type>d:text</type>
<constraints>
<constraint type="LIST">
<parameter name="allowedValues">
<list>
<value>Aprovado</value>
<value>Reprovado</value>
</list>
</parameter>
</constraint>
</constraints>
</property>
</properties>
<overrides>
<property name="bpm:outcomePropertyName">
<default>{ecmrepromaq.com.br/workflow/1.0}reviewOutcome3</default>
</property>
</overrides>
</type>
My Share-Config:
<config evaluator="task-type" condition="wfRepromaq:analiseComercialPedido">
<forms>
<form>
<field-visibility>
<show id="bpm:workflowDescription" />
<show id="packageItems" />
<show id="bpm:comment" />
<show id="wfRepromaq:ObsAnaliseCredito" />
<show id="wfRepromaq:reviewOutcome3" />
</field-visibility>
<appearance>
<field id="packageItems" read-only="true"/>
<field id="bpm:workflowDescription" label-id="workflow.field.message" read-only="true">
<control template="/org/alfresco/components/form/controls/textarea.ftl">
<control-param name="style">width: 95%</control-param>
</control>
</field>
<field id="wfRepromaq:reviewOutcome3" read-only="false">
<control template="/org/alfresco/components/form/controls/workflow/activiti-transitions.ftl" />
</field>
</appearance>
</form>
</forms>
</config>
What i have to do to the field "wfRepromaq:ObsAnaliseCredito" load with value informed before ?
Thanks!!
I think what you need to do is more on the workflow :
you need to pass your param in a taskListener (complete event) to your next step :
<userTask id="alfrescoUsertask1" name="taskName" activiti:assignee="${initiator.properties.userName}" activiti:formKey="wfRepromaq:analisarCredito">
<extensionElements>
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string> <![CDATA[execution.setVariable('wfRepromaq_ObsAnaliseCredito', task.getVariable('wfRepromaq_ObsAnaliseCredito'));]]></activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
</userTask>
...

OData function returning a collection of entities fails with PowerQuery

I got this error while using PowerQuery on a OData service I’m currently developing:
When writing a JSON response, a user model must be specified and the
entity set and entity type must be passed to the
ODataMessageWriter.CreateODataEntryWriter method or the
ODataFeedAndEntrySerializationInfo must be set on the ODataEntry or
ODataFeed that is being written.
This occurs when invoking from PowerQuery a bound function that returns a collection of entities. When invoked from a web browser, the response is (JSON format):
{
"#odata.context": "http://localhost:8080/ODataPrototype/ODataPrototype.svc/$metadata#Collection(Demo.ODataPrototype.Count)",
"value": [
{
"RowCount": 1
},
{
"RowCount": 2
},
{
"RowCount": 3
},
{
"RowCount": 4
}
]
}
I use the Olingo V4 library. A stripped down version of my metadata would be:
<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
<edmx:DataServices>
<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="Demo.ODataPrototype">
<EntityType Name="Instance">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="Edm.Int32" />
<Property Name="Name" Type="Edm.String" />
<Property Name="Description" Type="Edm.String" />
<Property Name="Tag" Type="Edm.String" />
<Property Name="Xid" Type="Edm.Int64" />
<Property Name="Properties" Type="Collection(Demo.ODataPrototype.Property)" />
</EntityType>
<EntityType Name="Count">
<Property Name="RowCount" Type="Edm.Int32" />
</EntityType>
<ComplexType Name="Property">
<Property Name="Name" Type="Edm.String" />
<Property Name="Value" Type="Edm.String" />
</ComplexType>
<Function Name="GetData" EntitySetPath="Instance/Demo.ODataPrototype.Count" IsBound="true">
<Parameter Name="Instance" Type="Demo.ODataPrototype.Instance" />
<Parameter Name="From" Type="Edm.DateTimeOffset" />
<Parameter Name="To" Type="Edm.DateTimeOffset" />
<ReturnType Type="Collection(Demo.ODataPrototype.Count)" />
</Function>
<EntityContainer Name="Container">
<EntitySet Name="Instances" EntityType="Demo.ODataPrototype.Instance"></EntitySet>
<EntitySet Name="Count" EntityType="Demo.ODataPrototype.Count" />
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
Would anyone know what I'm missing?
I found the solution. The context in my JSON response defines the result as a collection of type IVserver.ODataPrototype.Count:
"#odata.context": "http://localhost:8080/ODataPrototype/ODataPrototype.svc/$metadata#Collection(IVserver.ODataPrototype.Count)"
But PowerQuery needs an entityset:
"#odata.context": "http://localhost:8080/ODataPrototype/ODataPrototype.svc/$metadata#Count"
The EntitySet "Count" must be declared in the EntityContainer.
To get the EntitySet in the #odata.context, an entityset must be set when building the ContextURL. Example:
final ContextURL contextURL = ContextURL.with().entitySet(responseEdmEntitySet).selectList(selectList).serviceRoot(baseURI).build();
And, the methods asCollection() and type() must not be called.

ANT - How i cant move File to JAR

i've had edited my ANT build process. Here is my working list:
create a copy of the src folder and a selfwritten AntTask Obfuscated all Strings
ANT creates an JAR with <jar>
the JAR will be Obfuscated by ProGuard
An additional file will must be copied to the JAR
JAR will be signed
The bodled step is my Question. How i can copy a single file to the root directory of the JAR. I must make this step here! Before or after won't work: Before: ProGuard will be try to obfuscate this file and gives Exceptions. After cant work, the file must be signed.
Anyone have an smart idea?
Here a minified version of my ANT build script:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<project basedir="." default="default" name="DEMO">
<property environment="env" />
<property name="debuglevel" value="source,lines,vars" />
<property name="target" value="1.7" />
<property name="source" value="1.7" />
<!-- Applet Informationen -->
<property name="version" value="1.0.0" />
<!-- Start Build process -->
<target name="default">
<echo message="Copy source" />
<delete dir="builds/temp/" />
<mkdir dir="builds/temp/" />
<copydir src="src" dest="builds/temp/" />
<echo message="Obfuscate Strings" />
<taskdef resource="task.properties" classpath="libs/MyStringHelper.jar" />
<mystringhelper dir="builds/temp/" name="_X.class" decoder="MyClass.myMethod" imports="import test.MyClass;" />
<javac srcdir="builds/temp/" destdir="bin" />
<sleep seconds="1" />
<echo message="Create JAR Archive with Version ${version}" />
<jar destfile="builds/${name}${version}.jar" basedir="bin">
<manifest>
<attribute name="Application-Name" value="${name}" />
<attribute name="Application-Library-Allowable-Codebase" value="*.domain.com localhost" />
<attribute name="Caller-Allowable-Codebase" value="*.domain.com localhost" />
<attribute name="Codebase" value="*.domain.com localhost" />
<attribute name="Permissions" value="all-permissions" />
<attribute name="Author" value="Adrian Preuss" />
<attribute name="Main-Class" value="main.Run" />
</manifest>
</jar>
<echo message="Obfuscate the Archive" />
<taskdef resource="proguard/ant/task.properties" classpath="libs/proguard.jar" />
<proguard printmapping="proguard.map" overloadaggressively="off" repackageclasses="" renamesourcefileattribute="SourceFile">
<injar file="builds/${name}${version}.jar" />
<outjar file="builds/__${name}${version}.jar" />
<libraryjar file="${java.home}/lib/rt.jar" />
<libraryjar file="libs/ant.jar" />
<libraryjar file="libs/gradle-plugins-1.3.jar" />
<libraryjar file="libs/gradle-base-services-1.3.jar" />
<libraryjar file="libs/gradle-core-1.3.jar" />
<libraryjar file="libs/groovy-all-1.8.6.jar" />
<libraryjar file="libs/kenv.zip" />
<keeppackagename name="main" />
<keep access="public" name="main.Run">
<method access="public" type="void" name="changeLanguage" parameters="java.lang.String" />
</keep>
</proguard>
<delete file="builds/${name}${version}.jar" failonerror="false" />
<move file="builds/__${name}${version}.jar" tofile="builds/${name}${version}.jar" />
<!--
##
## ADD the File "builds/temp/_XA.class" to the JAR
##
## Info: the _XA.class is'nt an Java-Class file!
-->
<echo message="Roll up the code signing" />
<signjar jar="builds/${name}${version}.jar" alias="${name}" keystore="${name}.keystore" storepass="${password}" preservelastmodified="true" />
<echo message="Verify code signing" />
<verifyjar jar="builds/${name}${version}.jar" alias="${name}" storepass="${password}"/>
<echo message="Copy applet to local environment" />
<copy file="builds/${name}${version}.jar" tofile="C:/devsrv/htdocs/${name}${version}.jar" failonerror="false" />
<echo message="Cleanup,..." />
<!-- .... -->
</target>
</project>
This is a part from my ant build file including all xml, jpg, gif and png:
<!-- ============================================================== -->
<!-- Build application -->
<!-- ============================================================== -->
<target name="build" depends="make-bin-dir" description="Build application">
<javac srcdir="${src.dir}" destdir="${bin.dir}" debug="on" classpathref="javac.classpath" />
<copy todir="${bin.dir}">
<fileset dir="${src.dir}">
<include name="**/*.xml" />
<include name="**/*.jpg" />
<include name="**/*.gif" />
<include name="**/*.png" />
</fileset>
</copy>
</target>
To only include one file just put the full name in include name= "fullnamehere" />
Sorry...haven't seen your part to add...
Try it like this:
include name= "builds/temp/_XA.class" />
Since a Jar is really a Zip file, you could unzip the jar to a temp directory after proguard does its thing, add the _XA.class file where you want in in that temp dir, and re-create the jar file before signing.

Categories