d2010 soap error元素不包含单个文本节点

时间:2014-07-23 16:56:01

标签: web-services delphi soap

我搜索连接到Web服务,但是当我调用该方法时,我获得了此错误“Element”OutputObj“不包含单个文本节点”。

这是我创建导入我的WSDL文件的单位:

             // ************************************************************************ //
            // The types declared in this file were generated from data read from the
            // WSDL File described below:
            // WSDL     : D:\SVN\XML IE815\WSDL\DispatcherBean.wsdl
            //  >Import : D:\SVN\XML IE815\WSDL\DispatcherBean.wsdl>0
            //  >Import : D:\SVN\XML IE815\WSDL\DispatcherBean.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.

这是调用Web服务方法的代码:

            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; 

这是来自Web服务的XML响应:

<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>

当我调用GetDispatcherBean(False,'',HTTPRIO1,0).dispatcher(SOAP_RequestMsg)时,我得到了错误。

在RIO的BeforeExecute上,我只是控制XML请求它就像使用SoapUI的XML请求一样。

在RIO的AfterExecute上,我只是控制XML响应就像使用SoapUI的XML响应一样。

GetDispatcherBean(False,'',HTTPRIO1,0).dispatcher(SOAP_RequestMsg)返回一个MessageDTO,它是在UNDispatcherBean单元中定义的,但我认为Delphi没有正确解析对象MessageDTO的XML响应。

有关错误的任何想法?我必须在哪里寻找原因?

这是我的第一个使用Web Service和SOAP的项目,我希望不要写出这样的问题。

0 个答案:

没有答案