COM Compliant .NET Assembly Error when making a call to an Azure web service

  • Thread starter Thread starter e2bLou
  • Start date Start date
E

e2bLou

Guest
I have created a COM Compliant .NET Assembly that calls out to an Azure web service. This Assembly will be called from a VB 6 Program (Yes I said VB 6.. Long Story). Anyway, I have created COM Compliant Assemblies before to other web services and it was pretty straight forward to do. However, not this time. This time when I make a call to the DLL/Webservice from VB 6 I receive the error "An Error occurred while making the HTTP request to https:\... This could be due to the fact the server certificate is not configured properly with HTTP.SYS in the HTTPS Case. This could also be caused by a mismatch of the security binding between the client and server."

Using a Test .NET application calling the same methods, no error occurs and the DLL makes the necessary call to the web service. To verify the .NET DLL was working correctly for COM, I added a simple function to add two numbers, which worked fine when called from the VB 6 application. It is obviously an issue with COM and how it interacts with the web service.

The code that is used for both VB 6 and VB .NET is


Public Function TestService() As String
Dim _REsult As String = ""
Try
Dim _proxy As PTWebService.ApsWebServicesClient = GetWebServiceClient(c_WSAddress)
Dim _ctpRequest As PTWebService.CtpRequest = TestGetCTpRequest()
Console.WriteLine($"Sending CTP Request with {_ctpRequest.CtpRequestLines.Length} Lines")
Dim _Resp = _proxy.CTP("TestUser", "TestPwd", _ctpRequest)

_REsult = $"Sent CTP Request with {_ctpRequest.CtpRequestLines.Length} Lines" & Environment.NewLine & $"CTP Response received with return code: {_Resp.ReturnCode}"
Catch ex As Exception
_REsult = "Error [" + ex.Message.ToString() + "]"
End Try

Return _REsult
End Function

Private Function TestGetCTpRequest() As PTWebService.CtpRequest
Dim _ctpRequest As PTWebService.CtpRequest = New PTWebService.CtpRequest

_ctpRequest.ReserveMaterialsAndCapacity = False
_ctpRequest.SchedulingType = ESchedulingType.Optimize

Dim ctpRequestLines As List(Of PTWebService.CtpRequestLine) = New List(Of PTWebService.CtpRequestLine)() From {
New PTWebService.CtpRequestLine() With {
.LineId = 1,
.ItemExternalId = "FinishedGood 1",
.WarehouseExternalId = "Main Warehouse",
.RequiredQty = 100,
.NeedDate = DateTime.Now.Add(TimeSpan.FromDays(7)),
.Priority = 10
}
}

_ctpRequest.CtpRequestLines = ctpRequestLines.ToArray

Return _ctpRequest
End Function

Private Function GetWebServiceClient(c_WSAddress As String) As PTWebService.ApsWebServicesClient

If c_WSAddress = "" Then
Throw New Exception("No Address provided")
End If

Dim _Binding As BasicHttpBinding = New BasicHttpBinding(BasicHttpSecurityMode.Transport)

With _Binding
.BypassProxyOnLocal = True
.CloseTimeout = New TimeSpan(0, 2, 0)
.OpenTimeout = New TimeSpan(0, 2, 0)
.SendTimeout = New TimeSpan(0, 2, 0)
.AllowCookies = False
.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard
.MaxBufferPoolSize = 524288
.MaxBufferSize = Int32.MaxValue
.MaxReceivedMessageSize = Int32.MaxValue
.TextEncoding = Encoding.UTF8
.TransferMode = TransferMode.Buffered
.MessageEncoding = WSMessageEncoding.Text

End With

Return New PTWebService.ApsWebServicesClient(_Binding, New EndpointAddress(c_WSAddress))
End Function
This is the first time, I have made a call to an Azure web service, so compared to the other web services I have built interfaces for maybe I am missing something related to working Azure so it can work with VB 6. Any suggestions would be appreciated.

Lou Davis Software Engineer E2B Teknologies

Continue reading...
 
Back
Top