HTTP Authorization in SOAP delphi

时光毁灭记忆、已成空白 提交于 2021-02-08 10:52:39

问题


I am trying to send a request to web service, this is the WSDL: http://www.smsmelli.com/class/sms/webservice/server.php?wsdl

after long researching I underestand untyped array should replace with array of array of string; till here, it solved, but I realize my SOAP doesn't work properly. I check PHP action that works exactly same, then I find it sets Credential in Authentication in the header of HTTP from SOAP;

in WireShark:
-HyperText Transfer Protocol
--Authorization: Basic Y3LIZ577838sdf=
---Credentials: YourUserName:YourPassWord

how can I set that in Delphi 7 with HTTPRIO SOAP?


回答1:


I don't know about Delphi 7, but in XE2 the THTTPRIO has a HTTPWebNode property, which has settings for username and password.

In the BeforePost of the HTTPWebNode you can do detailed manipulation of the HTTP headers, like:

procedure TFrmTestEWS.HTTPRIO1HTTPWebNode1BeforePost(
  const HTTPReqResp: THTTPReqResp; Data: Pointer);
const
   CONTENT_HEADER_EX2010 = 'Content-Type: text/xml; charset=utf-8';
begin
   // http://forum.delphi-treff.de/archive/index.php/t-31817.html
   // Need to exchange the Content-Type Header, because Exchange 2010 expects
   // 'Content-Type: text/xml; charset=utf-8' instead of
   // 'Content-Type: text/xml; charset="utf-8"' which is RFC conform and used by XE2
   HttpAddRequestHeaders(Data, PChar(CONTENT_HEADER_EX2010), Length(CONTENT_HEADER_EX2010), HTTP_ADDREQ_FLAG_REPLACE);
end;

Hope this helps
Jan



来源:https://stackoverflow.com/questions/14174853/http-authorization-in-soap-delphi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!