none
how to consume my wcf service hosted in IIS from vb6 application RRS feed

  • Question

  • Hi all

    I am having wcf service which is hosted in IIS how can i consume that service from vb6 application. Provide some set of codes.

    Thanks in Advance

    George.Santhosh


    My vb6 Code is

    Function CallService()
    Const ForReading = 1
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile("c:\serviceWsdl.xml", ForReading)
    wsdlContract = objFile.ReadAll
    objFile.Close
    
    
    wsdlMonikerString = "service4:address='http://localhost/WCFLIBXML/WCFLibXML.Service1.svc'"
    wsdlMonikerString = wsdlMonikerString + ", wsdl='" & wsdlContract & "'"
    wsdlMonikerString = wsdlMonikerString + ", binding=wsHttpBinding,         bindingNamespace='http://Microsoft.ServiceModel.Samples' "
    wsdlMonikerString = wsdlMonikerString + ", contract=WCFLibXML.IService1, contractNamespace='http://Microsoft.ServiceModel.Samples' "
    Set wsdlServiceMoniker = GetObject(wsdlMonikerString)
    MsgBox "WSDL service moniker: 145 - 76.54 = " & wsdlServiceMoniker.Subtract(145, 76.54)
    End Function
    
    I am getting the following error
    Run-time error '-2147221020(800401e4)':
    Automation error
    Invalid syntax

     


    Wednesday, January 18, 2012 2:49 PM

All replies

  • Hello, please upgrade to .NET, and then you can simply add a service reference. If you have problems with VB6, find a VB6 forum.
    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
    If you have feedback about forum business, please contact msdnmg@microsoft.com. But please do not ask technical questions in the email.
    Thursday, January 19, 2012 1:36 AM
  • Hi I know its easy to consume the service in .net. Give some valid reply.
    santhosh kumar
    Thursday, January 19, 2012 12:55 PM
  • Santhosh,

    I did a bit of searching on the web and found the following blog post that may be helpful: http://blogs.msdn.com/b/a_pasha/archive/2006/09/25/770709.aspx. You may also want to take a look at this article: http://msdn.microsoft.com/en-us/library/bb735856.aspx

    I hope this is helpful,

    Michael Green
    WCF Documentation Team

     

    Thursday, January 19, 2012 9:53 PM
  • @Michale Green

    Hi Thanks for your reply.

    I can't understand the point 4. Use the Service reference in your form. which you have mentioned in that blog.

    Is it possible to consume the WCF service which is hosted in IIS. I am using SOAP BasicHttpBinding. Give your feedback.

     


    santhosh kumar
    • Edited by george.santhosh Friday, January 20, 2012 10:34 AM clarification required
    Friday, January 20, 2012 8:40 AM
  • Take a look at this thread on the VB forum: http://www.vbforums.com/showthread.php?t=558239
    It explains the different options you have.

    Personally, I would implement a small .NET dll (registered for COM interop) that calls the WCF service, your VB6 application can call that .NET 'helper' dll. This is certainly the simplest option that leaves all features of WCF open...
    The only prerequisite for this solution is that your clients have access to the .NET Framework.

     

     

     

    Friday, January 20, 2012 10:20 AM
  • That means to use the proxy class that svcutil generated in the Interop Form project.

    Michael Green
    WCF Documentation Team

    Friday, January 20, 2012 6:22 PM
  • Georgy,

    Did you try any of the proposed solution?

    What option will you take to consume the WCF servcie from VB6?


    If this post answers your quenstion, please mark it as such. If this post is helpful, click 'Vote as helpful'.
    Monday, January 23, 2012 8:33 AM
  • Peter Borremans

    I have posted the code what i have used but its not working. I also used the VB Interop form library , that is i have created the proxy class for my service with the use of svcutil(cs version) and i used that class in my interop project and added that dll in GAC and try to utilize the function but still i am not able to call the service.

    Because once i used the proxy class with (service1.cs) its not accessible from my Interop form. If i used the vb version of the proxy class its available in introp form, but i have to  change my project framework to 4.0 then only System.ServiceModel is available. If i used like that, that is my interop project to framwork 4.0. I am not able to add the reference of the interop form in my vb project.

    Give some code to accomplish this one.


    santhosh kumar
    Monday, January 23, 2012 9:27 AM
  • @Michal Green

     I also used the VB Interop form library , that is i have created the proxy class for my service with the use of svcutil(cs version) and i used that class in my interop project and added that dll in GAC and try to utilize the function but still i am not able to call the service.

    Because once i used the proxy class with (service1.cs) its not accessible from my Interop form. If i used the vb version of the proxy class its available in introp form, but i have to  change my project framework to 4.0 then only System.ServiceModel is available. If i used like that, that is my interop project to framwork 4.0. I am not able to add the reference of the interop form in my vb project.

    Give some code to accomplish this one.
    santhosh kumar
    Monday, January 23, 2012 9:27 AM
  • Hi to all

    Finally got solution to consume the WCF Service with mex and Wsdl. Thanks for the support.

     

    Here is the code to consume the WCF service from VB6

     

    The Below function will user the Metadata Exchange Contract Service Moniker

    Function DynamicMex()
    Dim quoteProxy, moniker, result
    moniker = "service:mexAddress=http://localhost:8732/wcfDynamicMexandWsdl/Service1/mex, "
    moniker = moniker + "address=http://localhost:8732/wcfDynamicMexandWsdl/Service1/,"
    moniker = moniker + "contract=IService1, "
    moniker = moniker + "contractNamespace=http://tempuri.org/, "
    moniker = moniker + "binding=WSHttpBinding_IService1, "
    moniker = moniker + "bindingNamespace=http://tempuri.org/"
    Set quoteProxy = GetObject(moniker)
    result = quoteProxy.GetData(20)
    MsgBox (result)
    End Function

     

    The Below function will user the WSDL Contract Service Moniker

    Function DynamicWsdl()
    Dim quoteProxy, wsdl, moniker, result, result1
    wsdl = GetWsdlFromUrl("http://localhost/vbclient/wcfDynamicMexandWsdl.Service1.svc?wsdl")
    moniker = "service:wsdl=" & wsdl & ", "
    moniker = moniker + "address=http://localhost/vbclient/wcfDynamicMexandWsdl.Service1.svc,"
    moniker = moniker + "contract=IService1, "
    moniker = moniker + "contractNamespace=http://tempuri.org/, "
    moniker = moniker + "binding=WSHttpBinding_IService1, "
    moniker = moniker + "bindingNamespace=http://tempuri.org/"
    Set quoteProxy = GetObject(moniker)
    result = quoteProxy.GetData(20)
    MsgBox (result)
    End Function

    Function GetWsdlFromUrl(strUrl)
    Dim WinHttpReq, resp
    Set WinHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")
    resp = WinHttpReq.Open("GET", strUrl, False)
    WinHttpReq.Send
    GetWsdlFromUrl = WinHttpReq.ResponseText
    End Function


    santhosh kumar
    Monday, January 23, 2012 4:29 PM
  • Hi to all the above code is working fine when we create a WCF library with wsHttpbinding. If i create the same thing WCF Application the above code is not working fine.

    Run-time erro '-2147221020(800401e4)':

    Automation error

    Invalid syntax

    Kindly give some solution for that

     

    Thanks in Advance

    G. Santhosh


    santhosh kumar
    Tuesday, January 24, 2012 5:44 PM
  • Hi All,

    I was trying to implement WCF Service Moniker using WSDL Contract for Complex Input and Output Types, but didn't get any sample/article for that. Did anyone have worked on Complex Types.

    Thanks in Advance.

    I am following this article.

    http://msdn.microsoft.com/en-us/library/ms752245

    Regards,

    Tapas

    Monday, February 27, 2012 5:58 PM
  • Hi Santhosh even I too facing the same problem from couple of days .Did u get the solution for this ? When i tried with WCF Library it is working fine But not with WCF Application .Please let me know if you have got the solution for this .

    Thanks In Advance ,

    Wednesday, March 21, 2012 2:36 PM
  • All,

    Did you guys got this working?

    Saturday, June 8, 2019 6:28 PM
  • All,

    Did you guys got this working?


    I kind of doubt it. :)
    Sunday, June 9, 2019 11:37 AM