ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Getting a Proxy Class into VBA (https://www.excelbanter.com/excel-programming/310904-getting-proxy-class-into-vba.html)

Paul Hastings[_2_]

Getting a Proxy Class into VBA
 
Hi All -

I am trying to build a Web Service that can be accessed using an Excel
spreadsheet. I have been able to do this for relatively simple access to the
Web Service. But now I need to add authentication using a client certificate
and that is where I am stuck.

It seems like the web reference that is created by the Web Reference thing
in Excel is not quite what I need. I looked at some of the articles on
client authentication and it said I need a web service proxy class like the
one that can be generated with WSDL.exe. I was able to generate the proxy
class using WSDL outside of Excel VBA.

My question: How do I get the Web Service proxy class into Excel? If I just
past the code into a new module it has all kinds of compile errors. What am
I doing wrong?

I am including the code generated by WSDL for a HelloWorld example but I
dont know how to get this code into VBA.

Thanks,

Paul Hastings
Principal Computer Scientist
Jorge Scientific Corporation




- - - Web Service Proxy Class for HelloWorld example - - -

'---------------------------------------------------------------------------
---
' <autogenerated
' This code was generated by a tool.
' Runtime Version: 1.1.4322.573
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </autogenerated
'---------------------------------------------------------------------------
---

Option Strict Off
Option Explicit On

Imports System
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Xml.Serialization

'
'This source code was auto-generated by wsdl, Version=1.1.4322.573.
'

'<remarks/
<System.Diagnostics.DebuggerStepThroughAttribute() , _
System.ComponentModel.DesignerCategoryAttribute("c ode"), _
System.Web.Services.WebServiceBindingAttribute(Nam e:="HelloWorldSoap",
[Namespace]:="http://PTH/HelloWorld/HelloWorld") _
Public Class HelloWorld
Inherits System.Web.Services.Protocols.SoapHttpClientProtoc ol

'<remarks/
Public Sub New()
MyBase.New
Me.Url = "https://pth/HelloWorld/HelloWorld.asmx"
End Sub

'<remarks/

<System.Web.Services.Protocols.SoapDocumentMethodA ttribute("http://PTH/Hello
World/HelloWorld/HelloWorld",
RequestNamespace:="http://PTH/HelloWorld/HelloWorld",
ResponseNamespace:="http://PTH/HelloWorld/HelloWorld",
Use:=System.Web.Services.Description.SoapBindingUs e.Literal,
ParameterStyle:=System.Web.Services.Protocols.Soap ParameterStyle.Wrapped)
_
Public Function HelloWorld() As String
Dim results() As Object = Me.Invoke("HelloWorld", New Object(-1) {})
Return CType(results(0),String)
End Function

'<remarks/
Public Function BeginHelloWorld(ByVal callback As System.AsyncCallback,
ByVal asyncState As Object) As System.IAsyncResult
Return Me.BeginInvoke("HelloWorld", New Object(-1) {}, callback,
asyncState)
End Function

'<remarks/
Public Function EndHelloWorld(ByVal asyncResult As System.IAsyncResult)
As String
Dim results() As Object = Me.EndInvoke(asyncResult)
Return CType(results(0),String)
End Function
End Class

- - - End of Web Service Proxy Class for HelloWorld example - - -




All times are GMT +1. The time now is 05:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com