locked
Error calling third-party asmx-webservice from CRM Online Plugin RRS feed

  • Question

  • Hi, 

    I need some help with a CRM Online plugin, the plugin has to call a third party asmx webservice, and it's giving an "SocketException: A connection attempt failed because the connected party did not properly respond after a period of time". Below you can find the complete error message. 

    Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Microsoft.Xrm.Sdk.InvalidPluginExecutionException: System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 212.666.666.25:8090
       at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
       at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
       --- End of inner exception stack trace ---
       at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
       at System.Net.HttpWebRequest.GetRequestStream()
       at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
       at CallOpportunityWebservice.blabla.crmopportunity.OpportunityService.GetOpportunity(Guid oppertunityGuid)
       at CallOpportunityWebservice.CallOpportunityWebservice.Execute(IServiceProvider serviceProvider)
       at CallOpportunityWebservice.CallOpportunityWebservice.Execute(IServiceProvider serviceProvider)Detail: 
    <OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
      <ErrorCode>-2147220891</ErrorCode>
      <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
        <KeyValuePairOfstringanyType>
          <d2p1:key>OperationStatus</d2p1:key>
          <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">0</d2p1:value>
        </KeyValuePairOfstringanyType>
      </ErrorDetails>
      <Message>Microsoft.Xrm.Sdk.InvalidPluginExecutionException: System.Net.WebException: Unable to connect to the remote server ---&gt; System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 212.666.666.25:8090
       at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
       at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket&amp; socket, IPAddress&amp; address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception&amp; exception)
       --- End of inner exception stack trace ---
       at System.Net.HttpWebRequest.GetRequestStream(TransportContext&amp; context)
       at System.Net.HttpWebRequest.GetRequestStream()
       at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
       at CallOpportunityWebservice.blabla.crmopportunity.OpportunityService.GetOpportunity(Guid oppertunityGuid)
       at CallOpportunityWebservice.CallOpportunityWebservice.Execute(IServiceProvider serviceProvider)
       at CallOpportunityWebservice.CallOpportunityWebservice.Execute(IServiceProvider serviceProvider)</Message>
      <Timestamp>2012-05-22T14:48:28.7483349Z</Timestamp>
      <InnerFault i:nil="true" />
      <TraceText>
    
    [CallOpportunityWebservice: CallOpportunityWebservice.CallOpportunityWebservice]
    [8ac15228-6e93-e111-b0a5-1cc1de086845: CallOpportunityWebservice.CallOpportunityWebservice: Update of opportunity]
    
    
    </TraceText>
    </OrganizationServiceFault>
    

    This is what I did: 

    - created a plugin

    - add reference to the webservice

    - upload plugin with plugin registration tool

    When I test the plugin, it results in a 'SocketException'. 

    In the beginning, I thought something was wrong with the webservice. I therefore created a webservice myself, and when I ran the plugin (with a reference to this homemade webservice) the plugin run succesful. So, you would think that there was something wrong with the third-party webservice. However, when I call the third-party webservice from a console-program, I am able to call the third-party webservice. 

    Now I'm lost, help is much appreciated! Below you find my code: 

    try
    {
    	crmopportunity.OpportunityService spService = new crmopportunity.OpportunityService();
    	spService.Url = "http://topsecretservername:8090/opportunityservice/opportunityservice.asmx";
    	var returnCode = spService.GetOpportunity(opportunityId);
    	throw new InvalidPluginExecutionException(string.Format("webservice call succesfull? returnCode = '{0}'", 
    		returnCode.ToString(CultureInfo.InvariantCulture)));
    }
    catch (Exception exception)
    {
    	throw new InvalidPluginExecutionException("Exception:" + exception.ToString());
    }

    Best regards, Leonard


    Wednesday, May 23, 2012 8:17 AM

Answers

All replies