Hi,
Can we pass user name and password in AddHeader method of roUrlTransfer? What is the appropriate way of sending soap header with web service request of ASP.NET?
Thanks
Malik
Hi,
Can we pass user name and password in AddHeader method of roUrlTransfer? What is the appropriate way of sending soap header with web service request of ASP.NET?
Thanks
Malik
Yup. For basic HTTP authentication, it should look something like this:
http = CreateObject("roUrlTransfer")
http.SetPort(CreateObject("roMessagePort"))
http.SetUrl("http://someurl.com")
http.AddHeader("Content-Type", "application/x-www-form-urlencoded")
ba = CreateObject("roByteArray")
ba.FromAsciiString("username:password")
http.AddHeader("Authorization", "Basic " + ba.ToBase64String())
http.EnableEncodings(true)
return http
Thanks for your reply. I already tried it but when I check header fields in Request Header only five header fields found and the field name “Authorization” is not in the list. If I pass any dummy field name in header it is passed exactly. I found following fields in request header:
But the field named “Authorization” is not there. Here is my code:
http = CreateObject("roUrlTransfer")
http.SetUrl("http://someurl.com")
ba = CreateObject("roByteArray")
ba.FromAsciiString("naeem:1234")
http.AddHeader("Content-Type", "application/x-www-form-urlencoded")
http.AddHeader("Authorization", "Basic " + ba.ToBase64String())
http.Http.EnableEncodings(true)
Why “Authorization” field is not add in request header?
Thanks
Malik
Your line “http.Http.EnableEncodings(true)” looks out of place.
The http object in this sample is an roUrlTransfer component. There is no additional Http field for this component. Even if you changed to http.EnableEncodings(true), I don’t think you are intending to enable gzip encodings.
Note that if you add the “Content-Type” header, you should be doing a POST with the properly formatted application/x-www-form-urlencoded payload.
It looks like you’ve implemented the Basic Auth, Authorization header correctly otherwise…
–Kevin