Fazer uma PerguntaFazer uma Pergunta
 

RespondidoWCF Dynamic Proxy (Microsoft)

  • quarta-feira, 22 de agosto de 2007 14:00Sachin Chitran Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     

    Hi,

     

    I downloaded the code form the link "WCF Dynamic Proxy (Microsoft)" to generate dynamic proxies.It works very fine.

    But the senario which is covered in that is for using http,

     

    I tried the dynamic proxy code for https and certificates(client and server) and it is failing.

     

    Can anyone help me in this regards?

     

    Sachin

Respostas

  • quarta-feira, 22 de agosto de 2007 14:28Allan-Nielsen Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     Respondido

    hi,

    are you running into this error here :

     - The remote certificate is invalid according to the validation procedure.

     

    a quick solution (no not dirty ) would be to skip validation by using code like this:

     

    Code Snippet

    ServicePointManager.ServerCertificateValidationCallback +=
                    new System.Net.Security.RemoteCertificateValidationCallback(ReturnTrueInThisCallBackFunctionHere);

     

     

    hth, Allan

  • quinta-feira, 23 de agosto de 2007 14:58Allan-Nielsen Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     Respondido

    hi,

    assuming clientCredentialType = "Certificate".

     

    you will have to set the client certificate on the dynamicproxy.

     

    now the proxy does not have support for this, but you can extend the proxy beyond recognition of course .

     

    start by creating a public method on the DynamicProxy (derived from  DynamicObject)

     

    Code Snippet

    public ClientCredentials Credentials
    {
         get
         {
           return (ClientCredentials)base.GetProperty("ClientCredentials");
         }

    }

     

     

     

    from your client code you can now set the certificate on the proxy.

     

    Read more on this subject here

    http://msdn2.microsoft.com/en-us/library/ms733102.aspx

     

    I am not sure if this subject here is more a DynamicProxy thing than a WCF in general related question, if so the wcf list moderator can stop this thread....

     

    but for now you should be armed with all you need to continue your work with this dynamic proxy.

     

    hth, Allan

     

Todas as Respostas

  • quarta-feira, 22 de agosto de 2007 14:28Allan-Nielsen Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     Respondido

    hi,

    are you running into this error here :

     - The remote certificate is invalid according to the validation procedure.

     

    a quick solution (no not dirty ) would be to skip validation by using code like this:

     

    Code Snippet

    ServicePointManager.ServerCertificateValidationCallback +=
                    new System.Net.Security.RemoteCertificateValidationCallback(ReturnTrueInThisCallBackFunctionHere);

     

     

    hth, Allan

  • quarta-feira, 22 de agosto de 2007 18:22David Kreutz - MSFTModeradorMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     

     

    Can you provide more detailed information on the failures?  Exceptions you are seeing, error messages, etc.
  • quinta-feira, 23 de agosto de 2007 8:58Sachin Chitran Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     

    Hi,

     

    I am getting this error

     

    The document at the url https://.../addion.svc was not recognized as a known document type.
    The error message from each known type may help you fix the problem:
    - Report from 'DISCO Document' is 'There was an error downloading 'https://.../addion.svc?disco'.'.
      - The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
      - The remote certificate is invalid according to the validation procedure.
    - Report from 'WSDL Document' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.
    - Report from 'https://.../addion.svc' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.
    - Report from 'XML Schema' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.

     

    Regards

    Sachin

  • quinta-feira, 23 de agosto de 2007 9:05Sachin Chitran Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     

     

    One more senario :- I have the url as https://.../addition.svc and I try to generate proxy through "Add Service Reference". It gives me same error....

     

    -Sachin

  • quinta-feira, 23 de agosto de 2007 9:09Christian WeyerMVPMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     

    Aha, so it seems you have some basic problems with the SSL config then?

    Can you enable tracing on the service side to get more erro dsta?

     

  • quinta-feira, 23 de agosto de 2007 9:15Allan-Nielsen Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     

    okay I should be more explict here, I ran into the exact same issue here and if you do as I told in my previous post, it should fix your issue.

     

    thanks Allan

     

  • quinta-feira, 23 de agosto de 2007 12:47Sachin Chitran Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     

     

    Hi Allan,

     

    Where do i write that code ?

     

    Sachin

  • quinta-feira, 23 de agosto de 2007 13:41Allan-Nielsen Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     

     

    Hi,

    before you call into the dynamic proxy.

     

    you probably have some client kode that creates an instance of the dynamic proxy, you can place that validation check in your client start up code

     

    int main()

    {

    validationcode.

    call dynaproxy

     

    }

     

    I hope it solves your problem, it did the trick for me last year I remember.

    Allan

  • quinta-feira, 23 de agosto de 2007 14:10Sachin Chitran Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     

    Hi Allan,

     

      It worked......Smile Thanks a ton........

     

    Well there is another problem now. The proxy is created but when i try to call the method in servcer i get following error..

     

    Message : Exception has been thrown by the target of an invocation.

    and

    Inner Exception : The client certificate is not provided. Specify a client certificate in ClientCredentials.

     

    I have added the code i am using and ablove mentioned exception is genrated in red marked line.

     

     

    ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(ValidateCertificate);

    DynamicProxy additionProxy = factory.CreateProxy("IAddition");

    // Call the Add service operation.

    DynamicDataContract value1 = new DynamicDataContract(factory.ProxyAssembly);

    value1.NumberOne = 10;

    value1.NumberTwo = 20;

    try

    {

    Int32 result = (Int32)additionProxy.CallMethod("Add", value1.ObjectInstance);

    }

    catch (Exception ex)

    {

    Console.WriteLine(ex.Message);

    }

     

     

    Sachin....

     

  • quinta-feira, 23 de agosto de 2007 14:51Christian WeyerMVPMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     

    Well, are you providing the client's cert?

    In your code you do not - what does your config look like?

     

  • quinta-feira, 23 de agosto de 2007 14:58Allan-Nielsen Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     Respondido

    hi,

    assuming clientCredentialType = "Certificate".

     

    you will have to set the client certificate on the dynamicproxy.

     

    now the proxy does not have support for this, but you can extend the proxy beyond recognition of course .

     

    start by creating a public method on the DynamicProxy (derived from  DynamicObject)

     

    Code Snippet

    public ClientCredentials Credentials
    {
         get
         {
           return (ClientCredentials)base.GetProperty("ClientCredentials");
         }

    }

     

     

     

    from your client code you can now set the certificate on the proxy.

     

    Read more on this subject here

    http://msdn2.microsoft.com/en-us/library/ms733102.aspx

     

    I am not sure if this subject here is more a DynamicProxy thing than a WCF in general related question, if so the wcf list moderator can stop this thread....

     

    but for now you should be armed with all you need to continue your work with this dynamic proxy.

     

    hth, Allan

     

  • quinta-feira, 23 de agosto de 2007 15:03Sachin Chitran Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     

    Hi Christian,

     

    I am generating the proxy dynamically from the code i downloaded from following link

     

    http://wcf.netfx3.com/files/folders/development_tools/entry6148.aspx

     

    But the thing is that it works for url of http and fails to make proxy for https used with certificates(client and server).

    Allan told a solution and it worked but when i call the method of service i get that exception.

     

    We dont have any config file.

     

    Sachin

  • quinta-feira, 23 de agosto de 2007 15:14Sachin Chitran Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     

     

    Sorry Allan to bother you ,but could you please tell me more in detail what should I do. I am totally new in this technology so I have very lil idea.

     

    Thanks for undertsnding

    Sachin

  • quinta-feira, 23 de agosto de 2007 15:32Allan-Nielsen Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     

    btw...

    speaking of .... I can resist ...must ... tell ... the world.

     

     

    Take 1 Dynamic proxy.

    stuff in some MetadataResolver for service discovery.

    Add 1 SQL 2005 server (design a pub/sub schema....inspired by BTS 2006 schema)

    Add some nice looking Infragistics controls for setting up publish/subscription.

    Add a simple pub/sub service contract (make sure you handle XmlSerializer and DataContractSerializer correctly).

    Finish off with one ounce of WWF for message retry handler.

    add some secret ingredients for transformation.

     

    Stir and cook it for a month and you will end up with:

     

    a home grown Enterprise Service Bus, loosely coupled 0xBABE.

     

     

    sorry for this OT , hope you guys find some inspiration here.

     

    @llan

  • quinta-feira, 23 de agosto de 2007 16:13Christian WeyerMVPMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     
    Show us the link to the baby! Smile

     

  • quinta-feira, 23 de agosto de 2007 16:34Allan-Nielsen Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     

    Christian....I can't, I would have to kill you afterwards ...

    but I have been talking to Mr. X about some code review...so one cold december morning perhaps

     

    @llan

  • sexta-feira, 24 de agosto de 2007 4:59Sachin Chitran Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     

    Hi Allan,

     

    Thanks a lot .. It is working. Your help has been of great help to me and community. Thanks a ton.

     

    Sachin

  • quarta-feira, 27 de fevereiro de 2008 16:25marco_il_serio Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     
    Hi,
    i'm testing WCF Dynamic Proxy but i have a problem.
    When i create a DynamicProxyFactory i receive this error: "There was an error in importing the metadata".
    Wsdl URL is http://webservices.dotnethell.it/codicefiscale.asmx?wsdl.
    Can you help me?