d2010 soap error element does not contain a single text node


d2010 soap error element does not contain a single text node



I search to connect to a Web service but when I call the method I obtain this error "Element "OutputObj" does not contain a single text node'.



This is the Unit I create importing my WSDL file:


// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : D:SVNXML IE815WSDLDispatcherBean.wsdl
// >Import : D:SVNXML IE815WSDLDispatcherBean.wsdl>0
// >Import : D:SVNXML IE815WSDLDispatcherBean.wsdl>1
// Encoding : UTF-8
// Version : 1.0
// (16/07/2014 9.33.06 - - $Rev: 25127 $)
// ************************************************************************ //

unit UNDispatcherBean;

interface

uses InvokeRegistry, SOAPHTTPClient, SOAPHTTPTrans, Types, XSBuiltIns;

const
IS_OPTN = $0001;
IS_UNBD = $0002;
IS_NLBL = $0004;
IS_UNQL = $0008;
IS_REF = $0080;


type
// ************************************************************************ //
// The following types, referred to in the WSDL document are not being represented
// in this file. They are either aliases[@] of other types represented or were referred
// to but never[!] declared in the document. The types from the latter category
// typically map to predefined/known XML or Embarcadero types; however, they could also
// indicate incorrect WSDL documents that failed to declare or import a schema type.
// ************************************************************************ //
// !:anyType - "http://www.w3.org/2001/XMLSchema"[Gbl]
// !:string - "http://www.w3.org/2001/XMLSchema"[Gbl]
// !:base64Binary - "http://www.w3.org/2001/XMLSchema"[Gbl]

MessageDTO = class; { "http://dto.domest.it.sogei"[GblCplx] }
XmlDTO = class; { "http://dto.domest.it.sogei"[GblCplx] }

ArrayOfXmlDTO = array of XmlDTO; { "http://dto.domest.it.sogei"[GblCplx] }


// ************************************************************************ //
// XML : MessageDTO, global, <complexType>
// Namespace : http://dto.domest.it.sogei
// ************************************************************************ //
MessageDTO = class(TRemotable)
private
FinputObj: Variant;
FoutputObj: Variant;
FserviceID: string;
FxmlList: ArrayOfXmlDTO;
public
destructor Destroy; override;
published
property inputObj: Variant Index (IS_NLBL or IS_UNQL) read FinputObj write FinputObj;
property outputObj: Variant Index (IS_NLBL or IS_UNQL) read FoutputObj write FoutputObj;
property serviceID: string Index (IS_NLBL or IS_UNQL) read FserviceID write FserviceID;
property xmlList: ArrayOfXmlDTO Index (IS_NLBL or IS_UNQL) read FxmlList write FxmlList;
end;

// ************************************************************************ //
// XML : XmlDTO, global, <complexType>
// Namespace : http://dto.domest.it.sogei
// ************************************************************************ //
XmlDTO = class(TRemotable)
private
Fxml: TByteDynArray;
published
property xml: TByteDynArray Index (IS_UNQL) read Fxml write Fxml;
end;


// ************************************************************************ //
// Namespace : http://dispatcher.domest.it.sogei
// soapAction: dispatcher
// transport : http://schemas.xmlsoap.org/soap/http
// style : document
// binding : DispatcherBeanSoapBinding
// service : DispatcherBeanService
// port : DispatcherBean
// URL : https://ws.agenziadogane.it/DomestRouter/services/DispatcherBean
// ************************************************************************ //
DispatcherBean = interface(IInvokable)
['{2D4F3F8E-969E-CF9A-EBAA-1C558EEF5A88}']
function dispatcher(const messaggio: MessageDTO): MessageDTO; stdcall;
end;

function GetDispatcherBean(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO=nil; PmTlmAmbiente: Integer=0): DispatcherBean;

implementation
uses SysUtils;

function GetDispatcherBean(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO; PmTlmAmbiente: Integer): DispatcherBean;
{PmTlmAmbiente
0 = Ambiente di addestramento
1 = Ambiente reale}
const
defWSDL_test = 'https://wstest.agenziadogane.it/DomestRouter/services/DispatcherBean/?wsdl';
defWSDL_real = 'https://ws.agenziadogane.it/DomestRouter/services/DispatcherBean/?wsdl';
defSvc = 'DispatcherBeanService';
defPrt = 'DispatcherBean';
defURL_real = 'https://ws.agenziadogane.it/DomestRouter/services/DispatcherBean';
defURL_test = 'https://wstest.agenziadogane.it/DomestRouter/services/DispatcherBean';
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
begin
// ambiente addestramento
if PmTlmAmbiente = 0 then
Addr := defWSDL_test;

// ambiente reale
if PmTlmAmbiente = 0 then
Addr := defWSDL_real;
end
else
begin
// ambiente addestramento
if PmTlmAmbiente = 0 then
Addr := defURL_test;

// ambiente reale
if PmTlmAmbiente = 1 then
Addr := defURL_real;
end;
end;
if HTTPRIO = nil then
RIO := THTTPRIO.Create(nil)
else
RIO := HTTPRIO;
try
Result := (RIO as DispatcherBean);
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;

destructor MessageDTO.Destroy;
var
I: Integer;
begin
for I := 0 to System.Length(FxmlList)-1 do
SysUtils.FreeAndNil(FxmlList[I]);
System.SetLength(FxmlList, 0);
inherited Destroy;
end;

initialization
InvRegistry.RegisterInterface(TypeInfo(DispatcherBean), 'http://dispatcher.domest.it.sogei', 'UTF-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(DispatcherBean), 'dispatcher');
InvRegistry.RegisterInvokeOptions(TypeInfo(DispatcherBean), ioDocument);
RemClassRegistry.RegisterXSInfo(TypeInfo(ArrayOfXmlDTO), 'http://dto.domest.it.sogei', 'ArrayOfXmlDTO');
RemClassRegistry.RegisterXSClass(MessageDTO, 'http://dto.domest.it.sogei', 'MessageDTO');
RemClassRegistry.RegisterXSClass(XmlDTO, 'http://dto.domest.it.sogei', 'XmlDTO');

end.



This is the code to call the Web Service method:


Procedure PrcSendSOAPRequest(const ServiceID:string; InputObj: Variant; PmPathXML: string);
{ServiceId
D1 : richiesta di Invio Draft IE815
D2 : richiesta Esito Invio Draft IE815 (IE801)
D3 : richiesta di Annullamento (IE810)
D4 : richiesta di Cambio Destinazione (IE813)
D5 : rischiesta di invio Appuramento (IE818)
D6 : richiesta di Rigetto (IE819)

InputObj
se ServiceID D2 : Protocollo di cui si vuole conoscere l'esito
}
var
FMEXPTXTEAD: TFMEXPTXTEAD;
SOAP_RequestMsg : MessageDTO;
SOAP_ResponseMsg : MessageDTO;
XMLDto_Element : XmlDTO;
XMLDtoArray : ArrayOfXmlDTO;
begin
FMEXPTXTEAD := TFMEXPTXTEAD.Create(Application);
try
with FMEXPTXTEAD do
begin
// richiesta di Invio Draft IE815
if ServiceID = D1 then
begin
XMLDto_Element := XmlDTO.Create;
SOAP_RequestMsg := MessageDTO.Create;
SOAP_ResponseMsg := MessageDTO.Create;
try
XMLDto_Element.xml := StringToByteArray(PmPathXML);
SetLength(XMLDtoArray, 1);
XMLDtoArray[0] := XMLDto_Element;

// MESSAGGIO DI RICHIESTA
SOAP_RequestMsg.serviceID := ServiceID;
SOAP_RequestMsg.xmlList := XMLDtoArray;

// MESSAGGIO DI RISPOSTA
SOAP_ResponseMsg := GetDispatcherBean(False,'',HTTPRIO1,0).dispatcher(SOAP_RequestMsg);

// LETTURA DEL MESSAGGIO DI RISPOSTA
PrcReadSOAPResponse(D1,SOAP_ResponseMsg);

finally
begin
XMLDto_Element.Free;
SOAP_RequestMsg.Destroy;
SOAP_ResponseMsg.Destroy;
end;
end;
end;
end;
finally
FMEXPTXTEAD.Close;
end;



and this is the XML Response from the Web Service:


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns2:dispatcherResponse xmlns:ns2="http://dispatcher.domest.it.sogei">
<dispatcherReturn>
<inputObj xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<outputObj xsi:type="ns4:XmlDTO" xmlns:ns4="http://dto.domest.it.sogei" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xml>Nzd1L1BEOTRiV3dnZG1WeWMybHZiajBpTVM0d0lpQmxibU52WkdsdVp6MGlkWFJtTFRnaVB6NEtQ</xml>
</outputObj>
<serviceID>D1</serviceID>
<xmlList>
<XmlDTO>
<xml>Nzd1L1BEOTRiV3dnZG1WeWMybHZiajBpTVM0d0lpQmxibU52WkdsdVp6MGlkWFJtTFRnaVB6NEtQ</xml>
</XmlDTO>
</xmlList>
</dispatcherReturn>
</ns2:dispatcherResponse>
</soapenv:Body>
</soapenv:Envelope>



When I call the GetDispatcherBean(False,'',HTTPRIO1,0).dispatcher(SOAP_RequestMsg) I obtain the error.



On the BeforeExecute of the RIO I just controll that the XML Request it's fine like a XML Request with SoapUI.



On the AfterExecute of the RIO I just controll that the XML Response it's fine like a XML Response with SoapUI.



The GetDispatcherBean(False,'',HTTPRIO1,0).dispatcher(SOAP_RequestMsg) Return an MessageDTO wich Class is define in the UNDispatcherBean Unit but I think Delphi don't parse correctly the XML Response to the Object MessageDTO.



Any idea about the Error ? Where I have to search the causes ?



It's my first project with Web Service and SOAP and I hope don't write estupid thigs.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

how to run turtle graphics in Colaboratory

Export result set on Dbeaver to CSV