开发者

How to set THTTPRio.Converter.Options to soLiteralParams in OnBeforeExecuteEvent

开发者 https://www.devze.com 2023-04-08 16:57 出处:网络
This refer to the post Delphi SOAP Envelope and WCF. Could someone please post a sample code which can show me how to set soLiteralParams in THTTPRio.Converter.Options in Delphi 7. I have the followi

This refer to the post Delphi SOAP Envelope and WCF.

Could someone please post a sample code which can show me how to set soLiteralParams in THTTPRio.Converter.Options in Delphi 7. I have the following code currently.

I have drag-dropped a HTTPRIO component into the document which has created a line HTTPRIO1: THTTPRIO at the beginning of the code. I basically want to understand how I set soLiteralParams in the above component. Following is the code I am trying to execute which is giving me error.

procedure TForm1.CleanUpSOAP(const MethodName: String; var SOAPRequest: WideString);
var RIO: THTTPRIO;
begin

  //The following line is giving error
//      RI开发者_高级运维O.Converter.options :=  [soLiteralParams];
end;

In the above code I have declared a variable RIO of the type THTTPRIO, which I am not sure is correct.


Just guessing, as you provide very little information in your question.

Use the variable assigned to the component you dropped on your form. Don't declare a new local one (which you never created anyway). To set the Converter.Options in code, you'll need to add OPToSOAPDomConv to your uses clause.

implementation

  uses 
    OPToSOAPDomConv;

// BTW, this name might not be a good one if it's the 
// OnBeforeExecute event handler as that isn't 
// clear from the name.
procedure TForm1.CleanUpSOAP(const MethodName: String; var SOAPRequest: WideString);
begin
  // Note this clears any previous options!
  HTTPRIO1.Converter.Options :=  [soLiteralParams];
  // If you want to keep the previous options instead of replacing them
  // HTTPRIO1.Converter1.Options := HTTPRIO1.Converter1.Options + [soLiteralParams];
end;

If you've dropped the component on the form, I'm not sure why you're not handling this in the Object Inspector instead, however.

If this doesn't solve the problem, edit your question and provide the exact error message you're receiving, including any memory addresses in the case of an exception being raised.


I have cracked this. The issue was that I didn't refer to OPconvert.pas file, which contained the TSOAPConvertOption enumeration. I don't know whether copying this file into the same folder as my project files and referring to this in the "uses" section is the right way, but it worked fine.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号