Ms dynamics merge two records using Java - 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.

Related

How to convert from String to IQ object in Smack

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

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.

Adding entity expansion before soap envelope in java

I want to code java program for the below example. I am not able to find the way to add Doctype before the soap envelope.
<?xml version="1.0"?>
<!DOCTYPE order SYSTEM "c:\order.dtd">
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body xmlns:m="http://www.example.org/order">
<order>
<cust_id>1</cust_id>
<cust_name>Bob Smith</cust_name>
<creditcardnum>999999999999</creditcardnum>
<creditcardexpiry>0609</creditcardexpiry>
<item>
<prod_id>1</prod_id>
<quantity>2</quantity>
</item>
</order>
</soap:Body>
</soap:Envelope>
In short, you shouldn't be adding a DOCTYPE to your SOAP messages, even if you somehow get it to work.
The slightly longer answer is that according to the specs for SOAP, a SOAP message MUST NOT contain a DTD. There are most likely a few reasons for this but there are definite concerns allowing DTD's as it opens the door for malicious attacks such as XXE (XML External Entity Attacks).
Here are some additional resources:
http://www.w3schools.com/xml/xml_soap.asp
https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Processing

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

DRM content with MM7 protocol Submit Request

I am creating a SOAP request to MMSC for posting DRM content (.dm file which is a 3gp video).
I am using Saaj API for the same.
The MMSC to which I sending the request to says that they need the SOAP request in the following format as its a 3gpp standards for submitting the SOAP request for a VASP.
POST / HTTP/1.1
Content-Type: multipart/related; boundary="XXX123456789PQR"; type=text/xml; start="<dna_003_mm7type>"
Content-Length: 14636
SOAPAction: ""
--XXX123456789PQR
Content-Type: text/xml; charset="utf-8"
Content-ID: <dna_003_mm7type>
<?xml version='1.0' ?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelop/">
<env:Header>
<mm7:TransactionID xmlns:mm7="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0"
env:mustUnderstand="1">dna_vasp_003</mm7:TransactionID>
</env:Header>
<env:Body>
<SubmitReq xmlns="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-3">
<MM7Version>5.6.0</MM7Version>
<SenderIdentification>
<VASPID>2222</VASPID>
<VASID>company</VASID>
</SenderIdentification>
<Recipients>
<To>
<Number>xxxxxxx</Number>
</To>
</Recipients>
<ServiceCode>gold-sp33-im42</ServiceCode>
<LinkedID>123456789</LinkedID>
<MessageClass>Informational</MessageClass>
<TimeStamp>2004-03-12T9:30:47-05:00</TimeStamp>
<EarliestDeliveryTime>2004-03-12T09:30:47-05:00</EarliestDeliveryTime>
<ExpiryDate>8400</ExpiryDate>
<DeliveryReport>true</DeliveryReport>
<ReadReply>true</ReadReply>
<ReplyCharging>true</ReplyCharging>
<replyDeadline>2004-05-12T9:30:47-05:00</replyDeadline>
<replyChargingSize>9198</replyChargingSize>
<Priority>Normal</Priority>
<Subject>News for today</Subject>
<ChargedParty>Sender</ChargedParty>
<DistributionIndicator>true</DistributionIndicator>
<Content href="cid:XYSFGA-135" allowAdaptations="true"/>
</SubmitReq>
</env:Body>
</env:Envelope>
--XXX123456789PQR
Content-Type: multipart/mixed; boundary="company"
--company
Content-Type: application/vnd.oma.drm.message; boundary="drm-boundary-409B8BD9"
Content-ID: base64_4.dm
Content-Location: base64_4.dm
--drm-boundary-409B8BD9
Content-Type: image/jpeg; name=scen2.jpg
Content-Location: scen2.jpg
Content-Transfer-Encoding: base64
/9j/4AAQSkZJRgABAAEAqgCqAAD//gAfTEVBRCBUZWNobm9sb2dpZXMgSW5j
LiBWMS4wMQD/2wCEABUODxIPDRUSERIXFhUZHzQiHx0dH0AuMCY0TENQT0tD
SUhUX3lmVFlyW0hJaY9qcn2Bh4mHUWWVn5OEnnmFh4IBFhcXHxsfPiIiPoJX
SVeCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKC
goKCgoKCgv/EAaIAAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKCwEAAwEB
AQEBAQEBAQAAAAAAAAECAwQFBgcICQoLEAACAQMDAgQDBQUEBAAAAX0BAgMA
BBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygp
KjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaH
/9k=
--drm-boundary-409B8BD9--
--company--
--XXX123456789PQR--
Can anyone pls suggest me what I need to do to send different MIME type for a single file attachment. Are there any Java API available to create such requests??? As using SAAJ, I am only to attach one MIME-TYPE for single attachment.
Are you sure you want to deliver .dm encoded files over MMS? DM is used for Separate-Delivery protection method and a handset will need to purchase and download rights in another transaction before content can be viewed. I'm pretty sure that a lot of handset doesn't even support it.
I had more success with MMS and DRM by simply using Forward-Lock protection. To use it, just wrap around a forward lock container in MM7 request.
To generate all this in java see https://stackoverflow.com/a/21663398/3290316

Categories