Ksoap2 Send Soap Request with Complex Object in Android - java

My xml has to be like this:
<d4p1:Criteria>
<d4p1:DestinationTelcoCenter i:nil="true" />
</d4p1:Criteria>
<d4p1:MyAccountName>m_sobati</d4p1:MyAccountName>
<d4p1:PagingInfo>
<d4p1:PageNo>1</d4p1:PageNo>
<d4p1:PageSize>10</d4p1:PageSize>
</d4p1:PagingInfo>
<d4p1:SortingInfo>
<d4p1:Direction>ASC</d4p1:Direction>
<d4p1:FieldName i:nil="true" />
</d4p1:SortingInfo>
I have to create this XML. I try do it with Ksoap2. But it doesn't work. How can I handle this?

Related

Parsing an XML in Java Spring

It's a really simple question but which I have no quick answer to it and I need help : I call a service that returns this XML body and need to parse it and get the element's values but for some reason I always get the values as null all the time.
How can I parse this XML body via any recommended method in java ?
<?xml version="1.0" encoding="UTF-8"?>
<Response xmlns="http://tempuri.org/Response.xsd">
<ResponseStatusDescription />
<EntityPaymentReceiptNumber />
<Description>Test</Description>
<OperationName>CheckPayment</OperationName>
<BankID>39</BankID>
<EntityPaymentDate />
<CheckPaymentID>188721103486</CheckPaymentID>
<ResponseStatusCode>INFO2</ResponseStatusCode>
</Response>
Generate a class from the xsd, i.e xjc http://tempuri.org/Response.xsd. Now, have your rest call expect Response as the return type.

How to read all the tags present inside entry tag based on tag name and store its value in a hashmap using java

Here is the xml code in which I want to get value based on tag name which are present under entry tag and store it in hashmap as a key value pair
<entry xmlns="http://www.w3.org/2005/Atom">
<title>Isra쭩쳳 doden drie Palestijnse aanvallers</title>
<updated>2016-02-17T17:13:11.477Z</updated>
<rights>This material may not be published</rights>
<content type="text/plain" xml:lang="nl">Isra쭩쳳 doden drie Palestijnse aanvallers</content>
<apcm:ContentMetadata xmlns:apcm="http://ap.org/schemas/03/2005/apcm">
<apcm:Priority Numeric="4" Legacy="r" />
<apcm:ConsumerReady>TRUE</apcm:ConsumerReady>
<apcm:ByLine>Paul Gabel</apcm:ByLine>
<apcm:HeadLine>Isra쭩쳳 doden drie Palestijnse aanvallers</apcm:HeadLine>
<apcm:OriginalHeadLine>Isra쭩쳳 doden drie Palestijnse aanvallers</apcm:OriginalHeadLine>
<apcm:Keywords>Westoever</apcm:Keywords>
<apcm:Cycle>BC</apcm:Cycle>
<apcm:Selector>-----</apcm:Selector>
<apcm:SlugLine>Westoever 2016/02/17 22:43:58</apcm:SlugLine>
<apcm:MediaType>Text</apcm:MediaType>
<apcm:SubjectClassification System="Editorial" Authority="AP Category Code" Value="DUT" Id="DUT" />
<apcm:Property Name="EntitlementMatch" Id="urn:publicid:ap.org:product:45147" Value="All Text for Elasticsearch" />
<apcm:Property Name="SequenceNumber" Value="InSequence" Id="236167493" />
<apcm:FirstCreated>2016-02-14T15:43:48Z</apcm:FirstCreated>
</apcm:ContentMetadata>
<apnm:NewsManagement xmlns:apnm="http://ap.org/schemas/03/2005/apnm">
<apnm:ManagementId>urn:publicid:ap.org:f02232ade7f4394d95337af4b9200c47</apnm:ManagementId>
<apnm:ManagementSequenceNumber>0</apnm:ManagementSequenceNumber>
</apnm:NewsManagement>
</entry>
Use JaxB. Java Architecture for XML Binding (JAXB) provides a fast and convenient way to bind XML schemas and Java representations, making it easy for Java developers to incorporate XML data and processing functions in Java applications.
example

Ms dynamics merge two records using Java

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.

MULE ESB -> SOAP mapping - Easy Method don't work

Hi all I'm new in Mule so please go easy on me. First of all I will show you example on SOAP UI:
Here is WSDL FILE: wsdl file
Its pretty easy. I want to make exacly the same mule flow (no input data etc - payload set in code). The problem is that I simple even can't start. I read tutorial:
http://www.mulesoft.org/documentation/display/current/XML-only+SOAP+Web+Service+Example
But still I can't do dataMappings like here. Any idea what I'm doing wrong my whole flow isn't big ... now its look like this:
<flow doc:name="PostRequest" name="PostRequest">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="getPostRequest" doc:name="HTTP" />
<cxf:jaxws-client operation="PostRequest" doc:name="SOAP"
enableMuleSoapHeaders="true" clientClass="pl.execon.integration.axpppk.ws.client.XISGateway"
port="XISGatewaySoap" />
<http:outbound-endpoint address="http://localhost:8889/Service/XISGateway.asmx" />
<object-to-string-transformer doc:name="Object to String" />
</flow>
I want to use PostRequest ... Any advices ? Tutorials that can help ? Problem is that I need to make this envelope modification:
<soap:Body>
<m:PostRequest>
<m:_requestCode>Test</m:_requestCode>
<m:GetGasCustTable>
<m:XMLDocumentTime>2014-07-21T12:24:50</m:XMLDocumentTime>
<m:CustAccount>00043280</m:CustAccount>
</m:GetGasCustTable>
</m:PostRequest>
</soap:Body>
And I Simply don't know how
If want to use post and map a webservice just use pattern this is a working code for post method:
<pattern:web-service-proxy name="webserviseName">
<inbound-endpoint address="http://localhost:8081/localUWant" exchange-pattern="request-response"/>
<outbound-endpoint address="http://localhost:8889/Service/XISGateway.asmx" exchange-pattern="request-response"/>
</pattern:web-service-proxy>
As simple as that.
this is the documentation: http://www.mulesoft.org/documentation/display/current/Using+Mule+Configuration+Patterns

Submit GET request to two servers

I have a production environment with two servers. I have a page where users submit data, and click save, and the database is updated with the information that was submitted. After this happens, I need to send a GET request to the two servers. These requests basically run methods to get the data that was updated, and save it into memory. I have been using jQuery to call the URLs like this:
$.ajax({<br />
type : "GET",<br />
url : 'http://IP_ADDRESS1/contextRoot1/servlet1?param=value&param2=value2'<br />
});
$.ajax({<br />
type : "GET",<br />
url : 'http://IP_ADDRESS1/contextRoot2/servlet1?param=value&param2=value2'<br />
});
$.ajax({<br />
type : "GET",<br />
url : 'http://IP_ADDRESS1/contextRoot3/servlet1?param=value&param2=value2'<br />
});
$.ajax({<br />
type : "GET",<br />
url : 'http://IP_ADDRESS2/contextRoot1/servlet1?param=value&param2=value2'<br />
});
$.ajax({<br />
type : "GET",<br />
url : 'http://IP_ADDRESS2/contextRoot2/servlet1?param=value&param2=value2'<br />
});
$.ajax({<br />
type : "GET",<br />
url : 'http://IP_ADDRESS2/contextRoot3/servlet1?param=value&param2=value2'<br />
});
I need to use the IP addresses of the machine because I have a load balancer, that forwards to requests to which ever machine is being least used when he gets a request to the domain. I am also pretty sure jQuery won't do 6 ajax requests. I am also having trouble with jQuery and the cross domain constraint. I tried using jQuery-xdomain-ajax.js, but it's a piece of junk (it didn't work for me). I kind of have a solution, but I am just wondering if there is a better one. My solution now is to have a popup open, and submit the other three ajax requests to the other server. I can't have an external process calling the request every so often.
Two app servers are JBoss with web servers that are Apache
One database server is MySQL
OS is linux on app servers and database server
Any help would be greatly appreciated.
If you need to put some data in a in memory store, you should use Infinispan the distributed cached bundle with JBoss as 7.
In this document you can find how to create a container and how to access the Inifinspan cache via injection.
With the use of Inifinspan each JBoss node will have access to the same shared cache and you will get scalable and highly available solution.

Categories