Конференция "Начинающим" » Call SAP Service without importing [D7]
 
  • A Memmedov (30.05.18 13:46) [0]
    Mne nujen ispolzovat SOAP service ne importiruya webservis. v C# est kod kotoriy rabotaet. Kak mojne eto delat ve delphi:

    C# COde:
       
               byte[] byteArray = Encoding.UTF8.GetBytes(xmlString);
               p_url="http://rvs.serviceadress.az:10004/WnRvsService.wsdl"
               WebRequest request = WebRequest.Create(p_url);
               request.Method = "POST";
               request.ContentType = "application/soap+xml";
               request.Credentials = new NetworkCredential(p_username, p_password);
               
               request.ContentLength = byteArray.Length;
               Stream dataStream = request.GetRequestStream();
               dataStream.Write(byteArray, 0, byteArray.Length);
               dataStream.Close();
               WebResponse response = request.GetResponse();
               dataStream = response.GetResponseStream();
               StreamReader reader = new StreamReader(dataStream);
               string responseFromServer = reader.ReadToEnd();
               reader.Close();
               dataStream.Close();
               response.Close();
               XmlDocument doc = new XmlDocument();
               doc.LoadXml(responseFromServer);
  • A Memmedov (01.06.18 11:17) [1]
    Uje nasel:

    Function GetSoapXMLResult(p_url,p_username,p_password, p_xmlstring:wideString): WideString;
     var
       IdHTTP     : TIdHTTP;
       XML_Result : WideString;


       response   : TStringStream;
     
       v_Request  : TStream;
        LHandler: TIdSSLIOHandlerSocketOpenSSL;
     begin
       Try
          LHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
         v_Request := TStringStream.Create(p_xmlstring, TEncoding.UTF8, true);

         IdHTTP := TIdHTTP.Create();
         IdHTTP.IOHandler:=LHandler;
         IdHTTP.Request.ContentType  :='application/soap+xml';
         IdHTTP.Request.BasicAuthentication:= true;
         IdHTTP.Request.Username := p_username;
         IdHTTP.Request.Password := p_password;
         response   := TStringStream.Create('', TEncoding.UTF8);
         IdHTTP.Response.ContentType     :='application/soap+xml';
         IdHTTP.Response.ContentEncoding :='UTF-8';

         IdHTTP.Post(p_url, v_Request, response);
         XML_Result :=response.DataString;

         v_Request.Free;
         response.Free;
         IdHTTP.Free;
       except on E: Exception do
         Begin
           XML_Result :=E.Message;

           v_Request.Free;
           response.Free;
           IdHTTP.Free;
         End;
       end;
       Result   :=XML_Result;

     end;
 
Конференция "Начинающим" » Call SAP Service without importing [D7]
Есть новые Нет новых   [134454   +44][b:0][p:0]