About the SOAP Web Services

The Sage CRM Blog

Articles of general interest about Sage CRM, the community, add-ons and general news!

About the SOAP Web Services

  • Comments 1
  • Likes

In another article as in this article I would like to consider the SOAP based Web Services for Sage CRM.

The SOAP based web services are very important because they are available to all currently supported versions of Sage CRM and they offer full CRUD (Create, Read, Update and Delete) functionality to developers.

The SOAP interface is available for installations of Sage CRM what ever the license key and so there is not additional cost implication for using the SOAP based web services.

SOAP is an XML based protocol for exchanging information between systems over the web. And another important term that needs to be known is WSDL.  The Web Services Description Language (WSDL) is an XML format that Sage CRM uses to publish the Object Types and Methods that are exposed by Sage CRM.  SOAP and WSDL are industry standards are by no means special to Sage CRM but what is defined using them is unique to Sage CRM.

The diagram below shows the basic conversation that might happen between a remote application and Sage CRM.

The application makes a request over the web (HTTP or HTTPS) in the form of an XML message.  This message is formatted in the SOAP standard and contains a structure that conforms to what the WSDL expects.

An example message might look like this:

[code language="xml"]<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header><SessionHeader xmlns="http://tempuri.org/type"><sessionId>133940176131748</sessionId>
</SessionHeader>
</soap:Header>
<soap:Body>
<query xmlns="http://tempuri.org/type">
<queryString>user_logon = 'Admin'</queryString>
<entityname>Users</entityname>
</query>
</soap:Body>
</soap:Envelope>
[/code] 

Sage CRM recieves the message and then unpacks it.  Depending on the message it will then query the database or insert or update data as necessary and build the response.  Any HTTP request will get a response and the response from Sage CRM will be formatted as a SOAP message:

[code language="xml"]
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<SOAP-ENV:Body><queryresponse xmlns="http://tempuri.org/type"><result><records xsi:type="typens:users" xmlns:typens="http://tempuri.org/type"><typens:userid>1</typens:userid><typens:primarychannelid>5</typens:primarychannelid><typens:logon>Admin</typens:logon><typens:lastname>Administrator</typens:lastname><typens:firstname>System</typens:firstname>
<typens:language>US</typens:language>
<typens:department>IS</typens:department><typens:phone>353 1 612 3456</typens:phone><typens:extension>3456</typens:extension><typens:mobilephone>086 803 4099</typens:mobilephone>
<typens:fax>353 1 612 3444</typens:fax><typens:emailaddress>admin@panoplytech.com</typens:emailaddress><typens:updatedby>-1</typens:updatedby><typens:updateddate>2010-12-13T11:12:46</typens:updateddate><typens:timestamp>2010-12-13T11:12:46</typens:timestamp><typens:per_contactinsert>0</typens:per_contactinsert><typens:per_contactupdate>3</typens:per_contactupdate><typens:per_communication>3</typens:per_communication><typens:per_opportunity>3</typens:per_opportunity><typens:per_case>3</typens:per_case><typens:per_todo>3</typens:per_todo><typens:per_channels>3</typens:per_channels><typens:per_reports>4</typens:per_reports><typens:per_admin>System Admin</typens:per_admin><typens:per_team>3</typens:per_team><typens:per_teamupdate>2</typens:per_teamupdate><typens:per_teamsensitive>2</typens:per_teamsensitive><typens:mustchangepassword>False</typens:mustchangepassword><typens:cannotchangepassword>False</typens:cannotchangepassword><typens:passwordneverexpires>True</typens:passwordneverexpires><typens:smsnotification>True</typens:smsnotification><typens:resource>Not Resource</typens:resource><typens:per_compassign>1</typens:per_compassign><typens:per_entitymerge>1</typens:per_entitymerge><typens:securityprofile>2</typens:securityprofile><typens:externallogonallowed>True</typens:externallogonallowed><typens:primaryterritory>Worldwide</typens:primaryterritory><typens:territoryprofile>Unrestricted Profile</typens:territoryprofile><typens:per_user>True</typens:per_user><typens:per_product>True</typens:per_product><typens:per_currency>True</typens:per_currency><typens:per_data>True</typens:per_data><typens:offlineaccessallowed>True</typens:offlineaccessallowed><typens:forecastcurrency>£</typens:forecastcurrency><typens:per_customise>True</typens:per_customise><typens:title>System Admin</typens:title><typens:location>Dublin</typens:location><typens:deskid>5/234A</typens:deskid><typens:istemplate>Not Template</typens:istemplate><typens:webserviceenabled>true</typens:webserviceenabled><typens:groupaccess>Yes</typens:groupaccess><typens:logons>15</typens:logons><typens:licencetype>Named</typens:licencetype><typens:territoriesfk>1</typens:territoriesfk></records><more>false</more></result></queryresponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
[/code]

What you can see from this is that the SOAP web services provide a mechanism for a remote application to interact with Sage CRM in order to read, create, update, or delete records for any exposed entity.  This could be Companies, People, Opportunities, Cases, Quotes and Orders. 

But the interface is only about data access.  It does not provide users with a GUI, which is the case with the .NET and COM APIs. Instead, Web Services share business logic, data, and processes. A developers can add the web service to a GUI, such as a Web page or an executable program, to provide users with the required functionality. 

The SOAP based web services are secure and easily controlled by the Sage CRM System Administrator.

The remote application has to log on as a user and a session is created that is monitored and stored in the user Activity tables as a clearly identifiable Web Service session.  

The system administrator can choose which entity is exposed to Web Services.

The WSDL from Sage CRM can be used by any Integrated Development Environment (IDE) such as Visual Studio as a web reference which enables the exposed objects and methods to be available within the intellisense of the program.  This makes programming with the Web Services a 'breeze' and Sage CRM provides an extensive set of C# snippets to speed the development process.

But a developer is not limited to any one programming language when working with the SOAP based Web Services.  Any language capable of formulating a SOAP request can be used whether it is java or php.  Furthermore the web services interface can be used to make AJAX (Asynchronous Javascript and XML) requests within the Sage CRM screens that allow an implementer to Mash-up new presentations of data within the screens.

If you would like to know more about the Web Services interface then a very good source of examples on how to code using the interface is found within the Hints, Tips and Trick partner blog within the the community.  This is actually a public blog so everyone should be able to access this.  https://community.sagecrm.com/search/SearchResults.aspx?q=web+services&ctypes=blog

There are other resources available for partners that include a sample application that demonstrates how to use the code, and a collection of C# snippets.

 

Comments
  • select comp_companyid,comp_name,rtrim(Phon_AreaCode)+rtrim(Phon_CountryCode)+Phon_Number from company

    join PhoneLink on PLink_EntityID = 5 and PLink_RecordID = comp_companyid

    join Phone on Phone.Phon_PhoneId = PhoneLink.PLink_PhoneId

    where rtrim(Phon_AreaCode)+rtrim(Phon_CountryCode)+Phon_Number = '6171720-1500'

    how can i put this query in ?