I'm making IQ requests for saving some data. In order to be synced with ejabberd server, I save IQ data to SQLite database in case of failure. So I convert IQ object to String by iqObject.toXML().toString(). But I'm stuck When I read from database and convert into IQ class.
My question is: How to convert following String to IQ class?
<iq type='set' id='1001'>
<query xmlns='urn:xmpp:contacts' clean="false" domain='localhost'>
<add>
<i id="1" number="+90">Mesut</i>
<i id="2" number="+91">Umit</i>
<i id="3" number="unknown">Unknown</i>
</add>
<delete>
<i id="4" />
<i id="5" />
</delete>
</query>
</iq>
Any helps would be very appreciated.
Best regards...
Update1
My smack version is: 4.5.0-alpha1
The problem is not related with neighter ejabberd nor openfire. It is exactly related with Smack
Atention please, the problem is not sending or receiving IQ packets. I make these works successfully. My question is how to send the String above over Smack as IQ stanza packet, so that receive appropriate IQ response.
You approach is true to convert that IQ object into XML, then String.
First you need to go through with the official document of ejabberd server website: https://www.ejabberd.im/IQ%20handlers/index.html
Now, you have to understand how IQ object raw packet are receiving in this thread: https://discourse.igniterealtime.org/t/how-can-i-create-send-and-receive-raw-iq-packet/71540
Related
Today I found the same http request to the backend api server, sometimes it could fetch the article, sometimes it could not fetch the article, this is my code:
Article article = articleMapper.selectByPrimaryKey(id);
and this is the code generate automaticlly using MyBatis Generator:
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
<!--
WARNING - #mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List" />
from article
where id = #{id,jdbcType=BIGINT}
</select>
the same http request, with the same article id. I do not know where is going wrong.My PostgreSQL version is 13. And this is my auto generate xml config:
<table tableName="article"
enableCountByExample="true"
enableUpdateByExample="true"
enableDeleteByExample="true"
enableSelectByExample="true"
selectByExampleQueryId="true">
<generatedKey column="ID" sqlStatement="JDBC" identity="true" />
</table>
any clue to figure out what wrong with the code? I am a newbie about PostgreSQL as backend database.
Does the article with the id you're querying for exist? Yes, I am sure the ID exists.
Could there be concurrent modifications? No, It is impossible. I will never edit the article after write into database. No transactions,The article is an old article.
I have downloaded the Ms Dynamics integration packages for Java (not the SDK). I am able to create, update and delete all entities. But now, I am trying to merge two contacts in Ms Dynamics Crm using Java. Research has led me nowhere. Classes like MergeRequest are there for JavaScript, but I am not sure how to go about with Java. I have created the two contacts, and have retrieved them.
I believe you use SOAP for CRUD operations. Here is Soap for Merging of records:
POST https://pactest.api.crm.dynamics.com/XRMServices/2011/Organization.svc/web
Content-Type: text/xml; charset=utf-8
SOAPAction: http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<Execute xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<request i:type="b:MergeRequest" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:b="http://schemas.microsoft.com/crm/2011/Contracts">
<a:Parameters xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
<a:KeyValuePairOfstringanyType>
<c:key>Target</c:key>
<c:value i:type="a:EntityReference">
<a:Id>00000000-0000-0000-0000-000000000000</a:Id>
<a:LogicalName>account</a:LogicalName>
<a:Name i:nil="true" />
</c:value>
</a:KeyValuePairOfstringanyType>
<a:KeyValuePairOfstringanyType>
<c:key>SubordinateId</c:key>
<c:value i:type="d:guid" xmlns:d="http://schemas.microsoft.com/2003/10/Serialization/">00000000-0000-0000-0000-000000000000</c:value>
</a:KeyValuePairOfstringanyType>
<a:KeyValuePairOfstringanyType>
<c:key>UpdateContent</c:key>
<c:value i:type="a:Entity">
<a:Attributes />
<a:EntityState i:nil="true" />
<a:FormattedValues />
<a:Id>00000000-0000-0000-0000-000000000000</a:Id>
<a:LogicalName>account</a:LogicalName>
<a:RelatedEntities />
</c:value>
</a:KeyValuePairOfstringanyType>
<a:KeyValuePairOfstringanyType>
<c:key>PerformParentingChecks</c:key>
<c:value i:type="d:boolean" xmlns:d="http://www.w3.org/2001/XMLSchema">true</c:value>
</a:KeyValuePairOfstringanyType>
</a:Parameters>
<a:RequestId i:nil="true" />
<a:RequestName>Merge</a:RequestName>
</request>
</Execute>
</s:Body>
</s:Envelope>
Of course you should replace Guid.Empty with correct ids of records you want to merge.
I need a basic Mule flow in order to select rows from one database, transform the payload and call a procedure in another database. I don't want to use DataMapper component, I would like to use Java Transformer instead.
My XML flow:
<set-variable variableName="currentOrder" value="#[payload.increment_id]" doc:name="Variable"/>
<db:select config-ref="MySQL_Configuration" doc:name="GET ORDER">
<db:parameterized-query><![CDATA[select id from sales where id=#[currentOrder]]]></db:parameterized-query>
</db:select>
<custom-transformer class="com.mycompany.transformers.TargerProc" doc:name="Java"/>
<db:stored-procedure config-ref="Oracle_Configuration" doc:name="PROC1">
<db:parameterized-query><![CDATA[call proc1(:P1,:P2)]]></db:parameterized-query>
<db:in-param name="P1" type="NUMERIC" value="#[payload.id]"/>
<db:out-param name="P2" type="NUMERIC" value=""/>
</db:stored-procedure>
First problem:
Message payload is of type: CaseInsensitiveHashMap
Could someone shed some light on this? I think it is really simple to achieve this.
Thanks in advance!
Try this <db:parameterized-query>{ call proc1(:P1,:P2) }</db:parameterized-query> :-
<set-variable variableName="currentOrder" value="#[payload.increment_id]" doc:name="Variable"/>
<db:select config-ref="MySQL_Configuration" doc:name="GET ORDER">
<db:parameterized-query><![CDATA[select id from sales where id=#[currentOrder]]]></db:parameterized-query>
</db:select>
<custom-transformer class="com.mycompany.transformers.TargerProc" doc:name="Java"/>
<db:stored-procedure config-ref="Oracle_Configuration" doc:name="PROC1">
<db:parameterized-query>{ call proc1(:P1,:P2) }</db:parameterized-query>
<db:in-param name="P1" type="NUMERIC" value="#[payload.id]"/>
<db:out-param name="P2" type="NUMERIC" value=""/>
</db:stored-procedure>
Mule version: 3,5 (Actually, mule studio)
I'm new at using mule and can't seem to figure out how to do the following properly:
Want to achieve:
Send data from a html form to mule which then splits the payload and sends one part to one java program and the other to another.
Html form:
<form method="GET" action="http://localhost:8081">
<input type="text" name="name"/>
<input type="text" name="lastname"/>
<input type="submit" value="Submit" />
</form>
This points to localhost and the port which is set in MuleStudio.
Real Question:
What could I use to transform the data from the inbound http to xml?
Side Question:
I can send the whole payload to one javaprogram. (first a POJO and then to the actual program. - is this the right way or can I send it to the program and skipping the POJO?)
Since your main concern is about transformation, let's only address it.
If you're using the Enterprise Edition, you can use DataMapper to generate the XML you need. Creating a schema representing the target XML would help a lot.
Otherwise, if you're using the Community Edition, you can use different options:
A Groovy component using the excellent MarkupBuilder to generate the target XML right from the inbound message payload,
A chain of standard transformers that first transform the submitted data to a generic XML form (object-to-xml-transformer) then transform it to the desired form (xslt-transformer).
I'm sure there are other options, but these should get you going :)
I'm receiving string from client like following -
String time_S = request.getParameter(Message.KEY_TIME);
Now, If I want to receive a linked list data how should I do that? I tried to use getParameterValues but I don't think I could use it properly.
Thanks in advance.
You can't really retrieve a 'linked list' per se over HTTP - it needs to be serialized (transformed from a Java object to a string). There are plenty of ways of doing this, but you might have them send it to you as a set of comma separated values and then parse it into a linked list or java data structure of your choice.
If you have them send if via JSON, there are several libraries that can be used which will change them to Java standard objects. Such as Simple.JSON, it turns JSON Array's into Java List objects, or JSON Object's into Java Map's.
getParameterValues might be the easiest way, provided that the client can provide each element of the list as a repeated querystring parameter.
For example if the client can send this querystring:
color=red&color=white&color=blue
getParameterValues("color") will return {"red", "white", "blue"}
Depends on how you submit the data. For example, if you submitting data from a web page and you are submitting data using the same parameter name, you can use the getParameterValues method.
For example, take the following inputs:
<input type="text" name="time" />
<input type="text" name="time" />
<input type="text" name="time" />
Then you can access the parameters as follows
String[] times = request.getParameterValues("time");
And if you need that linked list, just do the following
LinkedList<String> timeList = new LinkedList<String>(Arrays.asList(times));