Visual Studio 2010을 사용하여 간단한 ASMX 서비스를 구축했습니다. Delphi 7을 사용하여 간단한 서비스 클라이언트 응용 프로그램 (양식)을 작성했습니다. WSDLImport를 사용하여 모든 유형 정의가 포함 된 프록시 파일을 작성했습니다 및 서비스 운영. 다음은 WebService11.pas 파일의 코드입니다.델파이 클라이언트와 ASMX 서비스. 작업에 의해 수신되지 않는 데이터
unit WebService1;
interface
uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;
type
WebService1Soap = interface(IInvokable)
['{3392229C-09D2-6D56-CE62-6850ABB2629D}']
function Add(const a: Integer): Integer; stdcall;
function Subtract(const a: Integer; const b: Integer): Integer; stdcall;
end;
function GetWebService1Soap(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): WebService1Soap;
implementation
function GetWebService1Soap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): WebService1Soap;
const
defWSDL = 'http://localhost/DelphiTest/WebService1.asmx?wsdl';
defURL = 'http://localhost/DelphiTest/WebService1.asmx';
defSvc = 'WebService1';
defPrt = 'WebService1Soap';
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
Addr := defWSDL
else
Addr := defURL;
end;
if HTTPRIO = nil then
RIO := THTTPRIO.Create(nil)
else
RIO := HTTPRIO;
try
Result := (RIO as WebService1Soap);
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
finally
if (Result = nil) and (HTTPRIO = nil) then
RIO.Free;
end;
end;
initialization
InvRegistry.RegisterInterface(TypeInfo(WebService1Soap), 'http://tempuri.org/', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(WebService1Soap), 'http://tempuri.org/%operationName%');
end
.
다음은 Form1.pas 파일에 들어있는 파일의 실제 코드입니다.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, WebService1, InvokeRegistry, Rio, SOAPHTTPClient;
type
TForm1 = class(TForm)
Button1: TButton;
HTTPRIO1: THTTPRIO;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var c : integer;
begin
c := GetWebService1Soap(False,'',HTTPRIO1).Add(10);
ShowMessage(IntToStr(c));
end;
end.
예상대로 델파이 클라이언트가 ASMX 서비스를 때리고 있습니다. 그러나 "추가"작업에서 매개 변수로 보낸 데이터가 표시되지 않습니다. ASMX 서비스 소스 코드를 중단하고 null 인 매개 변수 값을 검사했습니다.
델파이 클라이언트가 보낸 메시지를 읽기 위해 피들러를 사용했지만 들어오는 SOAP 메시지를 볼 수 없습니다. 정수 값인 ASMX 서비스에 의해 다시 전송 된 SOAP 데이터를 볼 수 있습니다. 이 정수 값은 SOAP 클라이언트에 의해 수신되지 않습니다.
1) 전송 및 델파이 클라이언트에 의해 수신되는 것을 읽을 수있는 다른 방법이 있나요 :
나는 다음과 같은 이해할 필요가있다. Delphi에서 HTTPRIO1 구성 요소가 있다는 것을 알고 있지만 요청 및 응답 데이터를 얻는 방법을 모르겠습니다.
2) 여기서 잘못된 것은 무엇입니까?
* 아직 델파이 7 전문가가 아닙니다. 기본적으로 ASMX 서비스에 대한 델파이 클라이언트 대화를 얻으려고합니다. 그러므로 내가 SOAP 기반의 ASMX 서비스에 델파이 클라이언트의 이야기를 얻을 수 있는지 이해할 필요가, 나는 WCF를 사용할 수도 있지만, 내가 직면하고 약간의 복잡성이 1.1
나중에 추가 : 은 어떻게 든 요청을 수집 한 및 피들러를 통해 응답 SOAP 메시지 2.
요청 SOAP 메시지 :
<?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" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<NS1:Add xmlns:NS1="http://tempuri.org/">
<a xsi:type="xsd:int">10</a>
</NS1:Add></SOAP-ENV:Body>
</SOAP-ENV:Envelope>
응답 SOAP 메시지 :
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<AddResponse xmlns="http://tempuri.org/">
<AddResult>2</AddResult>
</AddResponse>
</soap:Body>
</soap:Envelope>
InvRegistry.RegisterInvokeOptions (TypeInfo (WebService1Soap), ioDocument); – Sam