Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Problems passing data from Plugin to Webservice since changing to HTTPS

Posted on by 255

Hi

I have a plugin that fires on Update and sends data through a webservice to update an external MSsql db.
All was fine but the project was parked for a while.

I've since gone back to it and now there's an issue with no data apparently getting to the webservice.

The only change to the system is that the Webservice now runs over httpS where as before when it worked it was http.

Would this cause my problem and if so how can I fix?

The parameterized query '(@FirstName nvarchar(4000),@LastName nvarchar(4000),@Email nvarc' expects the parameter '@FirstName', which was not supplied.


*This post is locked for comments

  • Stuie Profile Picture
    Stuie 255 on at
    RE: Problems passing data from Plugin to Webservice since changing to HTTPS

    Couldn't get this to work.

    Changed to a .Net Webservice asmx from wcf and all ok now

  • Stuie Profile Picture
    Stuie 255 on at
    RE: Problems passing data from Plugin to Webservice since changing to HTTPS

    I think the plugin is OK because I can use debug and trace all the data being generated right up to the point where the data is sent to the WS with "client.InsertUserDetails(userInfo);"

    It's at that point that I get the error back from the WebService about parameters not being supplied.

    I've since used this example to configure my WS but I'm still seeing the same problem.

    Arrrghh

    docs.microsoft.com/.../how-to-configure-an-iis-hosted-wcf-service-with-ssl

  • Stuie Profile Picture
    Stuie 255 on at
    RE: Problems passing data from Plugin to Webservice since changing to HTTPS

    Thank you.

    And is this how I'd use the function.

    CrmDataInsertClient client = new CrmDataInsertClient(GetBasicHttpsBinding("xxxxx.com/.../CrmDataInsert.svc"), endPointAddress);

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Problems passing data from Plugin to Webservice since changing to HTTPS

    Hi Stuie ,

    You need to change your plugin code accordingly -Here is sample code to dynamically  get the binding 

    // For Basic HTTP binding        
    public static BasicHttpBinding GetBasicHttpBinding(string anyName) { var _binding = new BasicHttpBinding { Name = anyName, Security = { Mode = BasicHttpSecurityMode.None }, AllowCookies = false, BypassProxyOnLocal = false, HostNameComparisonMode = HostNameComparisonMode.StrongWildcard, MaxBufferPoolSize = Int32.MaxValue, MaxBufferSize = Int32.MaxValue, MaxReceivedMessageSize = Int32.MaxValue, MessageEncoding = WSMessageEncoding.Text, TextEncoding = Encoding.UTF8, TransferMode = TransferMode.Buffered, UseDefaultWebProxy = true }; return _binding; }

    // For Basic HTTPS binding
    public static BasicHttpsBinding GetBasicHttpsBinding(string anyName) { var _binding = new BasicHttpsBinding { Name = anyName, AllowCookies = false, BypassProxyOnLocal = false, HostNameComparisonMode = HostNameComparisonMode.StrongWildcard, MaxBufferPoolSize = Int32.MaxValue, MaxBufferSize = Int32.MaxValue, MaxReceivedMessageSize = Int32.MaxValue, MessageEncoding = WSMessageEncoding.Text, TextEncoding = Encoding.UTF8, TransferMode = TransferMode.Buffered, UseDefaultWebProxy = true }; return _binding; }
  • Suggested answer
    sandeepstw Profile Picture
    sandeepstw 4,601 on at
    RE: Problems passing data from Plugin to Webservice since changing to HTTPS

    Hi Stuie,

    Please refer this link to use deployment mode -

    stackoverflow.com/.../dynamics-crm-plugin-calling-webclient-with-certificate-in-sandbox-mode

    and refer this to call from web client.

    social.msdn.microsoft.com/.../webclient-and-https

    Mark as verified if this helps.

    Thanks,

    Sandeep

  • Stuie Profile Picture
    Stuie 255 on at
    RE: Problems passing data from Plugin to Webservice since changing to HTTPS

    Hi. Thanks for the reply.

    I'm using this from my Plugin;

     myBinding.Name = "BasicHttpBinding_ICrmDataInsert";
     myBinding.Security.Mode = BasicHttpSecurityMode.Transport;
     myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
     myBinding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
     myBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
     EndpointAddress endPointAddress = new EndpointAddress("xxxxx.com/.../CrmDataInsert.svc");
     CrmDataInsertClient client = new CrmDataInsertClient(myBinding, endPointAddress);
     CRMDataWcfService.UserDetails userInfo = new CRMDataWcfService.UserDetails();

    and my .config file in the Plugin looks like this;

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="BasicHttpBinding_ICrmDataInsert" />
                </basicHttpBinding>
            </bindings>
            <client>
                <endpoint address=""
                    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICrmDataInsert"
                    contract="ICrmDataInsert" name="BasicHttpBinding_ICrmDataInsert" />
            </client>
        </system.serviceModel>
    </configuration>



  • David Jennaway Profile Picture
    David Jennaway 14,063 on at
    RE: Problems passing data from Plugin to Webservice since changing to HTTPS

    How do you connect to the web service ? If you use a .Net Service Reference, then you'll need to change the configuration (either in code, or the respective .config file) to use https. However, if you use a .Net Web reference, or some of the http or web classes, then you shouldn't need to change anything other than the url. Note also that the web service may also need configuration to support https.

    From the error, it looks like the issue is that you're either not passing a parameter, or the web service is not receiving it properly. This indicates that something else has probably also changed, as the changes just to use https shouldn't affect the parameters; in most cases the call would either succeed or fail

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans