Einzelnen Beitrag anzeigen

helste

Registriert seit: 16. Jul 2009
72 Beiträge
 
Delphi 10.1 Berlin Professional
 
#10

AW: SOAP Client Problem treibt mich in den Wahnsinn

  Alt 11. Feb 2019, 14:37
Ja, das hatte ich schon. Etwas anders zwar, aber sollte auch funktionieren. Habe so mal "<?xml version="1.0"?>" entfernt, obwohl das offensichtlich eh nicht stört. War nur um zu testen, ob mein Ansatz funktioniert.

Habe jetzt mal folgende Eventhandler drinnen:

Delphi-Quellcode:
procedure TForm1.HTTPRIOBeforeExecute(const MethodName: string;
  SOAPRequest: TStream);

var
   sl : tstringlist;

begin
sl := tstringlist.Create;
SOAPRequest.Position := 0;
sl.LoadFromStream(SOAPRequest);
response.Lines.Add ('Request');
response.Lines.Add (sl.Text);
response.Lines.Add ('--------------------------------------------------');
sl.Delete(0);
response.Lines.Add (sl.Text);
(SOAPRequest as TMemoryStream).Clear;
sl.SaveToStream(SOAPRequest);
sl.Free;
end;

procedure TForm1.HTTPRIOAfterExecute(const MethodName: string;
  SOAPResponse: TStream);

var
   sl : tstringlist;

begin
sl := tstringlist.Create;
SOAPResponse.Position := 0;
sl.LoadFromStream(SOAPResponse);
response.Lines.Add ('Response ------------------------------------------------------------------------------');
response.Lines.Add (sl.Text);
sl.Free;
end;


procedure TForm1.HTTPRIOHTTPWebNode1BeforePost(const HTTPReqResp: THTTPReqResp;
  Data: Pointer);

var
   s: String;
  Flag: LongBool;

begin
Flag := True;
s := 'Accept-Encoding: gzip,deflate';
HttpAddRequestHeaders(Data, PChar(s),
    Length(s), HTTP_ADDREQ_FLAG_ADD);
InternetSetOption(Data, INTERNET_OPTION_HTTP_DECODING,
    PChar(@Flag), SizeOf(Flag));


s := 'Content-Type: text/xml;charset=UTF-8';
HttpAddRequestHeaders(Data, PChar(s), Length(s), HTTP_ADDREQ_FLAG_REPLACE);

s := 'SOAPAction: "http://sap.com/xi/WebService/soap1.1"';
HttpAddRequestHeaders(Data, PChar(s), Length(s), HTTP_ADDREQ_FLAG_REPLACE);

s := 'Authorization: Basic ' + TNetEncoding.Base64.Encode('username:passwort');
HttpAddRequestHeaders(Data, PChar(s), Length(s), HTTP_ADDREQ_FLAG_REPLACE);

s := 'User-Agent: Apache-HttpClient/4.1.1 (java 1.5)';
HttpAddRequestHeaders(Data, PChar(s), Length(s), HTTP_ADDREQ_FLAG_REPLACE);

end;
Im Memofeld "response" steht dann am Ende folgendes drinnen:




Request
<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Body><ZECOM_EU_CATALOG_STATUS_WS xmlns="urn:sap-com:document:sap:rfc:functions"></ZECOM_EU_CATALOG_STATUS_WS></SOAP-ENV:Body></SOAP-ENV:Envelope>

--------------------------------------------------
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Body><ZECOM_EU_CATALOG_STATUS_WS xmlns="urn:sap-com:document:sap:rfc:functions"></ZECOM_EU_CATALOG_STATUS_WS></SOAP-ENV:Body></SOAP-ENV:Envelope>

Response ------------------------------------------------------------------------------
<html>
<head><title>MessageServlet</title></head>
<body>
<h3>Message Servlet is in Status OK</h3>
<h3>Status information:</h3>
Servlet com.sap.aii.adapter.soap.web.MessageServlet (Version $Id: //tc/xpi.adapters/NW731EXT_16_REL/src/_soap_application_web_module/webm/api/com/sap/aii/adapter/soap/web/MessageServlet.java#1 $) bound to /MessageServlet
<br/>Classname ModuleProcessor: null
<br/>Lookupname for localModuleProcessorLookupName: localejbs/ModuleProcessorBean
<br/>Lookupname for remoteModuleProcessorLookupName: null
<br/>ModuleProcessorClass not instantiated
<br/>ModuleProcessorLocal is Instance of com.sun.proxy.$Proxy1320
<br/>ModuleProcessorRemote not instantiated
</body></html>
  Mit Zitat antworten Zitat