sending xml via post, https request with certifica (General questions)
Hello,
is there a example available for our requirement.
If this is possible, we will buy the wodHttpDLX component.
We're reading the cert container with the function below.
Function get_certbyCN(iStoreNbr As Integer, strCommonName As String) As Certificate
' T.Genzel 2009
' Store 10 = Andere Personen (other persons)
Dim Location As CertLocation
Dim cert As Certificate
Dim i As Integer
Dim j As Integer
Set Location = New CertLocation
j = Location(0).Item(iStoreNbr).Count
For i = 0 To j - 1
Set cert = Location(0).Item(iStoreNbr).Item(i)
If (strCommonName = cert.CommonName) Then
Set get_certbyCN = cert
Exit Function
End If
Next i
get_certbyCN = cert
End Function
function http(data)
Set cert = get_certbyCN(10, customerdomain )
whttp.URL = https://www.customerdomain.com/request/
whttp.Timeout = 10
whttp.port = 443
whttp.Login = Cust
whttp.Password = CustomerPwd
Set whttp.Certificate = cert
whttp.Post https://www.customerdomain.com/request
Debug.Print whttp.State
Debug.Print whttp.Response.StatusCode
Debug.Print whttp.Response.Status
Debug.Print whttp.LastError & / & whttp.LastErrorText
end function
Two problems:
1.) got an error on loading cert
2.) sending is not possible
We need to send a XML via https method post with cert and login information.
Maybe there is a example from weonlydo
[:smile:]
Thanks for help.
Best reagards,
Torsten
Re: sending xml via post, https request with certi
Hi Torsten,
When you add this line before whttp.URL line in your code did you see your certificate?
[code]cert.Show ( My cert )[/code]
For uploading file can you please check our 5. Upload file to the server sample.
You can find it in VB\Component\5. Upload file to the server folder.
Let us know how it goes.
Regards,
Drazen
Re: sending xml via post, https request with certi
Hello Drazen,
thanks for your tip. The scenario is we gave the public key to our customer and sending the xml docs via private key to our customer.
Here are the solution ... draft
Function send_with_cert(Optional strUrl As String, Optional strXML As String)
' T.Genzel 2009
Dim cert As Certificate
Dim hFile As Long
Dim whttp As wodHttpDLX
Set whttp = New wodHttpDLX
Set cert = get_certbyCN(10, mycompany )
Debug.Print cert.CommonName
'cert.show ( My Cert )
Set whttp.Certificate = cert
cert.LoadKey ( load private key here )
whttp.ProxyType = ProxyWindows
whttp.ProxyAuthentication = AuthNTLM '
whttp.ProxyHostname = proxyadress
whttp.ProxyLogin = yourloginname
whttp.ProxyPassword = yourpwd
whttp.ProxyPort =
whttp.Blocking = True 'will return to your code until the command completes
whttp.Request.Headers.Add Content-type , text/xml; charset=utf-8
whttp.Timeout = 60
whttp.DebugFile = D: empinetpubfiledebug.txt
whttp.Request.Body = strXML
whttp.port = 443
whttp.URL = strUrl
On Error Resume Next
whttp.Post
'get resposne
'response.Write whttp.Response.Body
If whttp.Response.StatusCode = 200 Then
Debug.Print whttp.Response.Body
Else
Debug.Print ERROR - Status: & whttp.Response.StatusCode & whttp.Response.Status & <br>
Debug.Print whttp.LastErrorText & / & whttp.LastError
Debug.Print whttp.Response.Body
End If
whttp.DisConnect
Set whttp = Nothing
End Function
Now, we will wait for the customer, if there is a go we will buy the component.
Best regards,
Torsten