Friday, February 8, 2013

Call custom WCF Soap Service from Javascript

In my posts regarding oData, you can find JavaScript calls against WCF DataServices. Here i describe the call against a default WCF SOAP Endpoint.

WCF Service:
  public class Service1 : IService1 {
      public string GetData(int value) {
          return string.Format("You entered: {0}", value);
      }
  }

JavaScript:
function Retrieve(id) {
 jQuery.support.cors = true;
 var soapData = '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">' + '<s:Body><GetData xmlns="http://tempuri.org/"><value>200</value></GetData></s:Body></s:Envelope>';
 $.ajax({
     type: "POST",
     contentType: "text/xml; charset=utf-8",
     dataType: "xml",
     url: "http://localhost:58282/Service1.svc",
     data: soapData,
     beforeSend: function (xhr) {
       xhr.setRequestHeader("SOAPAction""http://tempuri.org/IService1/GetData");
     },
     success: RetrieveCallbackSuccess,
     error: RetrieveCallbackError
 });
}
function RetrieveCallbackSuccess(response) {     alert("Yey! :) --> " + response.text); }
function RetrieveCallbackError(err) {     alert("Onoz! :( --> " + err.statusText); }

The line "jQuery.support.cors = true" is important for cross domain requests.

Cheers,
Markus

Tuesday, February 5, 2013

CRM 2011 Instance Adapter - Connecting Organizations

I found a nice "little" application, released in december last year. It allows the connection of two Microsoft Dynamics CRM Instances (Organizations).

I have not tested it yet but it sounds very interesting for archiving or especially for Development Environments. Also Picklist-Values can be synced.

Microsoft Dynamics CRM 2011 Instance Adapter

There is also an Installation Video available.

Cheers,
Markus