RSS

Sending images from AX to Third party application through web services(custom services) in AX 2012

02 Jan

Hi Readers,

I have come across a situation where I was in need of sending the image of a worker to the third party application through web services.

So, I have written a method in the service class which will take the HCMWorker table person field as input. This method will find the image of the worker and convert that into XML element and finally to a string and will return it to the calling method(serialization and deserialization concept). Have a look at how I achieved this.

//[SysEntryPointAttribute(true)]
public str getImageXml(DirPartyRecId _person)
{
XmlDocument xmlEnvelope;
XmlElement childNode;
str content;
BinData bin = new BinData();
System.String myCLRString;
Str myXppString;
;

//creating BinData object from Container in the CompanyImage object
bin.setData(HcmPersonImage::findByPerson(_person).Image);
//encoding the image to base64
content = bin.base64Encode();
//creating the envelope and inserting a XmlElement that contains the image into a base64 string
xmlEnvelope = new XmlDocument();
childNode = xmlEnvelope.CreateElement(“image”);
childNode.innerXml(content);
xmlEnvelope.AppendChild(childNode);
myCLRString = xmlEnvelope.xml();
myXppString = myCLRString;
return myXppString;
}

Happy New Year Folks!!!

 
Leave a comment

Posted by on January 2, 2017 in AX

 

Tags: , , , ,

Leave a comment

 
Azure Integration services

Azure Integration services and integration patterns using Logic Apps, Azure Functions, Service Bus, Azure Data Factory and API management

Sunny's Blog on Dynamics AX

Exploring AX2012 and initiating knowledge sharing

Microsoft Dynamics 365 Blog

By Sandeep Chaudhury, Specialist in Microsoft Business Applications focused on Service and Project centric Organizations

D365FO/ AX Tips and Tricks

This blog is to help with AX issues

Moving on to D365 Finance and Operations

This blog is to help with AX issues

Dynamics AX Daily

This blog is to help with AX issues