Delphi llama a WebService para enviar mensajes SOPA directamente
¿Puede usar el control HTTPReqResp para enviar mensajes directamente
o usar el control TIdHTTP para solicitar la interfaz del protocolo SOAP de servicios web en http?
Función de muestra:
HTTPReq: THTTPReqResp;
función TDM_Demo.WebSrvMain(In_fkey_XML,In_funccode,In_fparam_XML:String):String;
var
?DataMsg:WideString;
* strStream, strSend: TStringStream;
comenzar
// Usar herramientas como SOPAUI para obtener el mensaje de muestra estándar DataMsg
?DataMsg:=''+
?' ?' xmlns:SOAP-ENC="http://schemas.xmlsoap. org/ SOAP/encoding/" '+ ?'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '+ ?' xmlns: xsd="http://www.w3.org/2001/XMLSchema">'+ ' ' ' ' ' ?''; ? strStream := TStringStream.Create(''); ? strSend := TStringStream.Create(AnsiToUtf8(DataMsg)); //Transcodificación Utf8 ?try HTTPReq.url := 'Dirección de servicio'; HTTPReq.Execute(strSend, strStream); resultado := strStream.DataString; resultado := UTF8Decode(resultado); //xml < ; >?"?Transcodificación resultado := StringReplace(resultado, '<', '<',[rfReplaceAll, rfIgnoreCase]); resultado := StringReplace(resultado, ' >', '>' ,[rfReplaceAll, rfIgnoreCase]); resultado := StringReplace(resultado,'"','"',[rfReplaceAll, rfIgnoreCase]); //Transformar a documento XMLDocument de Delphi resultado := StringReplace(resultado,'', ? ' ',[rfReplaceAll, rfIgnoreCase]); finalmente strStream.Free; strSend.Free; ?Gratis; strSend.Free; ? fin; fin; ¿Método de publicación de servicios web de solicitud http?Interfaz de protocolo SOAP con IdHttp comenzar ?ProtocolVersion := pv1_1; ? AllowCookies := True; ?ProxyParams.BasicAuthentication := False; ?ProxyParams.ProxyPort := 0; ?Request.ContentLength := -1 ; ?Request.Accept := 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'; ? Request.BasicAuthentication := False; ?Request.ContentType := 'application/x-www-form-urlencoded'; ?HTTPOptions := [hoKeepOrigProtocol, hoInProcessAuth] ; ?ReadTimeout:=5000; fin; strSend.WriteString(DataMsg); resultado:=IdHttp.Post (sWSDLAddr ,strEnviar); ?