Answered by:
CRM 2013 Online - Plugin calling external webservice

Question
-
Hi
I'm trying to create a POC for at customer, but I think I hit bottom here.
Im trying to connect to an external web service, which is hosted on a internal development server at the moment, through a CRM plugin.
Because the CRM enviroment is Online, my plugin has to be registered in sandbox.
When I run the plugin from CRM, Í get the following error:
My code looks like this:
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity) { Entity sag = (Entity)context.InputParameters["Target"]; Entity postImageEntity = (context.PostEntityImages != null && context.PostEntityImages.Contains("PostImage")) ? context.PostEntityImages["PostImage"] : null; OptionSetValue match = (OptionSetValue)postImageEntity["new_match"]; if (match.Value == 2) { string[] conditionFields = new string[] { "new_ediibilagndid" }; string[] conditionValues = new string[] { postImageEntity.Id.ToString() }; EntityCollection ediInds = RetrieveMultiRequest("new_ediind", conditionFields, conditionValues, service); if (ediInds.Entities.Count == 1) { foreach (Entity ediInd in ediInds.Entities) { var myBinding = new BasicHttpBinding(); myBinding.Security.Mode = BasicHttpSecurityMode.None; EndpointAddress endPointAddress = new EndpointAddress("http://wmsi003755:1234/FacadeService/FacadeService.svc"); FacadeService.FacadeServiceClient FSC = new FacadeService.FacadeServiceClient(myBinding, endPointAddress); //--------------------------------- string EDICpr = (string)ediInd.Attributes["new_cprnummer"]; Money EDIBeloeb = (Money)ediInd.Attributes["new_totaltoverfrtbelb"]; // FacadeServiceClient FSC = new FacadeServiceClient(myBinding, endPointAddress); FacadeService.OverfoerelseIndAiaRequest OAR = new FacadeService.OverfoerelseIndAiaRequest(); //APPension.Integration.Skema.Depot.OverfoerelseIndAiaRequest OAR = new APPension.Integration.Skema.Depot.OverfoerelseIndAiaRequest(); FacadeService.OverfoerelsePalDetaljer[] palListe = new FacadeService.OverfoerelsePalDetaljer[6]; // APPension.Integration.Skema.Depot.OverfoerelsePalDetaljer[] palListe = new APPension.Integration.Skema.Depot.OverfoerelsePalDetaljer[6]; palListe[0] = createPAL((EntityReference)ediInd.Attributes["new_palrnuvrender"], (Money)ediInd.Attributes["new_palbelbnuvrender"]); palListe[1] = createPAL((EntityReference)ediInd.Attributes["new_palr1"], (Money)ediInd.Attributes["new_palbelbr1"]); palListe[2] = createPAL((EntityReference)ediInd.Attributes["new_palr2"], (Money)ediInd.Attributes["new_palbelnr2"]); palListe[3] = createPAL((EntityReference)ediInd.Attributes["new_palr3"], (Money)ediInd.Attributes["new_palbelnr3"]); palListe[4] = createPAL((EntityReference)ediInd.Attributes["new_palr4"], (Money)ediInd.Attributes["new_palbelbr4"]); palListe[5] = createPAL((EntityReference)ediInd.Attributes["new_palr5"], (Money)ediInd.Attributes["new_palbelbr5"]); FacadeService.OverfoerelseIndAiaPaategning EksternSelskab = new FacadeService.OverfoerelseIndAiaPaategning(); //APPension.Integration.Skema.Depot.OverfoerelseIndAiaPaategning EksternSelskab = new APPension.Integration.Skema.Depot.OverfoerelseIndAiaPaategning(); EksternSelskab.Kode = "FRI004"; EntityReference afgivendeSelskab = (EntityReference)ediInd.Attributes["new_afgivendeselskabsnavn"]; EksternSelskab.Selskab = afgivendeSelskab.Name; EksternSelskab.StartDato = (DateTime)ediInd.Attributes["new_oprindeligtegningsdato"]; OAR.Cpr = (string)ediInd.Attributes["new_cprnummer"]; Money TotalOverfoertBeloeb = (Money)ediInd.Attributes["new_totaltoverfrtbelb"]; OAR.DepotBeloeb = TotalOverfoertBeloeb.Value; OAR.InternEkstern = FacadeService.OverfoerelseInternEkstern.Ekstern; //APPension.Integration.Skema.Depot.OverfoerelseInternEkstern.Ekstern; OAR.DepotOverfoerelseFonde = null; OAR.OpsparingDaekninger = null; OAR.Overenskomstnummer = "39170418-001"; //DENNE MANGLER I CRM Money ratePension = (Money)ediInd.Attributes["new_opsparingratepension"]; OAR.OverfoertRate = ratePension.Value; OAR.PalDetaljeListe = palListe; OAR.Policenummer = (string)ediInd.Attributes["new_policenummer"]; OAR.Proces = FacadeService.OverfoerelseProces.Crm; //APPension.Integration.Skema.Depot.OverfoerelseProces.Crm; OAR.Paategning = EksternSelskab; OAR.SkalVederlagAOpkraeves = false; OAR.SkalVederlagFOpkraeves = false; FacadeService.Identifikation Iden = new FacadeService.Identifikation(); //APPension.Integration.Skema.Identifikation Iden = new APPension.Integration.Skema.Identifikation(); Iden.Dato = DateTime.Today; Iden.JuridiskId = "112233-44"; Iden.Type = FacadeService.BrugerRolle.Kunde; //APPension.Integration.Skema.BrugerRolle.Kunde; FSC.OpretOverfoerelseIndAia(OAR, Iden);
Can anyone see, if this is possible at all?Monday, June 23, 2014 8:51 AM
Answers
-
ip addresses are not allowed inside sandbox plugins.
It's not important where is hosted the web service, the important is that is reachable from CRM Online and use a name, like http://www.mycompany.com/FacadeService/FacadeService.svc
the name http://wmsi003755:1234 is local, not visible outside your network.
My blog: www.crmanswers.net - Rockstar 365 Profile
- Proposed as answer by Guido PreiteMVP Monday, June 23, 2014 11:37 AM
- Marked as answer by Casper Schau1 Monday, June 23, 2014 1:51 PM
Monday, June 23, 2014 11:37 AM
All replies
-
Hi,
the problem is with your address: http://wmsi003755:1234/FacadeService/FacadeService.svcthis is clearly a local address (probably hosted on your machine) not reachable from CRM Online. You need to host your web service in public way (like azure)
My blog: www.crmanswers.net - Rockstar 365 Profile
- Proposed as answer by Guido PreiteMVP Monday, June 23, 2014 9:03 AM
Monday, June 23, 2014 9:03 AM -
But the address is hosted in iis on a server. I can reach the service is I use the ip address insted of servername, but that is not aloud in a sandbox plugin.Monday, June 23, 2014 11:28 AM
-
ip addresses are not allowed inside sandbox plugins.
It's not important where is hosted the web service, the important is that is reachable from CRM Online and use a name, like http://www.mycompany.com/FacadeService/FacadeService.svc
the name http://wmsi003755:1234 is local, not visible outside your network.
My blog: www.crmanswers.net - Rockstar 365 Profile
- Proposed as answer by Guido PreiteMVP Monday, June 23, 2014 11:37 AM
- Marked as answer by Casper Schau1 Monday, June 23, 2014 1:51 PM
Monday, June 23, 2014 11:37 AM -
-
Yes, azure or another public server
My blog: www.crmanswers.net - Rockstar 365 Profile
Monday, June 23, 2014 12:37 PM