回 帖 发 新 帖 刷新版面

主题:BCB中调用SOAP和DynamicArray

我调用一个SOAP服务,但得到的结果总为空.不知道是哪里出错了.恳请各位指点.十分感谢

WSDLLocation:http://www.adl.dk/xws/AdlGazeTalk?WSDL

NS_AdlGazeTalk::_di_SearchPortType SearchPort;   // import WSDL后会有相关定义.
NS_AdlGazeTalk::ArrayOfdk_kb_dup_adlGazeTalk_Author AuthorList;  // typedef DynamicArray ArrayOfdk_kb_dup_adlGazeTalk_Author;

void __fastcall TForm1::GetAuthorByNameClick(TObject *Sender)
{
    SearchPort = GetSearchPortType();
    [b]AuthorList = SearchPort->getAuthorsByName("T"); [/b]   //查询以T为开头的作者名.但AuthorList结果总为空.
   
    Memo1->Clear();

    for (int i=0; i< AuthorList.Length; i++){   // 结果显示不对
        Memo1->Lines->Add("Birth: " + IntToStr(AuthorList[i].birthYear));
        Memo1->Lines->Add("Death: " + IntToStr(AuthorList[i].deathYear));
        Memo1->Lines->Add("Facts: " + AuthorList[i].facts );
    }
 }

回复列表 (共7个回复)

沙发

把AuthorList = SearchPort->getAuthorsByName("T");替换为
(SearchPort->getAuthorsByName("T")).Copy(AuthorList);
后得到错误:
Classes with properties cant be copied by value
于是overload =,但又得到错误:
Vcl style classes must be constructed by operator new

我觉得应该不会这么复杂...SOAP返回一个complex object应该是
很常见的.请多指教...

板凳

SOAP调用的参数和返回参数类型是限制的,只能使用部分的类对象,不支持全部类对象。

3 楼

// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL     : http://www.adl.dk/xws/AdlGazeTalk?WSDL
// Encoding : UTF-8
// Version  : 1.0
// (2006-11-28 10:01:01 - $Revision:   1.0.1.0.1.82  $)
// ************************************************************************ //

#ifndef   AdlGazeTalkH
#define   AdlGazeTalkH

#include <System.hpp>
#include <InvokeRegistry.hpp>
#include <XSBuiltIns.hpp>
#include <SoapHTTPClient.hpp>


namespace NS_AdlGazeTalk {

// ************************************************************************ //
// 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 Borland types; however, they could also 
// indicate incorrect WSDL documents that failed to declare or import a schema type.
// ************************************************************************ //
// !:dk_kb_dup_adlGazeTalk_Author - "http://dk.kb.dup.adlGazeTalk/IAdlGazeTalk.xsd"
// !:dk_kb_dup_adlGazeTalk_Period - "http://dk.kb.dup.adlGazeTalk/IAdlGazeTalk.xsd"
// !:dk_kb_dup_adlGazeTalk_Work - "http://dk.kb.dup.adlGazeTalk/IAdlGazeTalk.xsd"
// !:string          - "http://www.w3.org/2001/XMLSchema"
// !:ArrayOfdk_kb_dup_adlGazeTalk_Author - "http://dk.kb.dup.adlGazeTalk/IAdlGazeTalk.xsd"
// !:ArrayOfdk_kb_dup_adlGazeTalk_Period - "http://dk.kb.dup.adlGazeTalk/IAdlGazeTalk.xsd"
// !:int             - "http://www.w3.org/2001/XMLSchema"
// !:ArrayOfdk_kb_dup_adlGazeTalk_Work - "http://dk.kb.dup.adlGazeTalk/IAdlGazeTalk.xsd"
// !:dk_kb_dup_adlGazeTalk_Page - "http://dk.kb.dup.adlGazeTalk/IAdlGazeTalk.xsd"
// !:dk_kb_dup_adlGazeTalk_Portrait - "http://dk.kb.dup.adlGazeTalk/IAdlGazeTalk.xsd"



// ************************************************************************ //
// Namespace : AdlGazeTalk
// transport : http://schemas.xmlsoap.org/soap/http
// style     : rpc
// binding   : SearchBinding
// service   : AdlGazeTalk
// port      : SearchPort
// URL       : http://adl.dk/xws/AdlGazeTalk
// ************************************************************************ //
__interface INTERFACE_UUID("{D015DA45-73C3-EC58-B907-586CC4172C47}") SearchPortType : public IInvokable
{
public:
  virtual dk_kb_dup_adlGazeTalk_Author getAuthor(const AnsiString authorId) = 0;
  virtual ArrayOfdk_kb_dup_adlGazeTalk_Author getAuthors() = 0;
  virtual ArrayOfdk_kb_dup_adlGazeTalk_Author getAuthorsByName(const AnsiString nameStart) = 0;
  virtual dk_kb_dup_adlGazeTalk_Period getPeriod(const AnsiString periodId) = 0;
  virtual ArrayOfdk_kb_dup_adlGazeTalk_Period getPeriods() = 0;
  virtual dk_kb_dup_adlGazeTalk_Work getWork(const AnsiString workId) = 0;
  virtual ArrayOfdk_kb_dup_adlGazeTalk_Work getAllWorks(const int maxNumberOfWorks) = 0;
  virtual ArrayOfdk_kb_dup_adlGazeTalk_Work getWorksByTitle(const AnsiString titleStart, const int maxNumberOfWorks) = 0;
  virtual ArrayOfdk_kb_dup_adlGazeTalk_Work getWorksByAuthor(const AnsiString authorId, const int maxNumberOfWorks) = 0;
  virtual dk_kb_dup_adlGazeTalk_Page getPage(const AnsiString workId, const AnsiString pageNumber) = 0;
  virtual dk_kb_dup_adlGazeTalk_Page getFirstPage(const AnsiString workId) = 0;
  virtual dk_kb_dup_adlGazeTalk_Portrait getAuthorPortrait(const AnsiString authorId) = 0;
  virtual dk_kb_dup_adlGazeTalk_Portrait getPeriodPortrait(const AnsiString periodId) = 0;
};
typedef DelphiInterface<SearchPortType> _di_SearchPortType;

_di_SearchPortType GetSearchPortType(bool useWSDL=false, AnsiString addr="");



#endif // __AdlGazeTalk_h__

};     // NS_AdlGazeTalk

#if !defined(NO_IMPLICIT_NAMESPACE_USE)
using  namespace NS_AdlGazeTalk;
#endif


看不到dk_kb_dup_adlGazeTalk_Author等类型声明啊,怎么帮你啊!?

4 楼

HI CSQCPU,

太感谢你的回帖 :)
我也试了一下,大概server那边又在改动把.
我把我机子里的两个import文件发了邮件给你.
请多多指点...
谢的话也不多说.我去programfan上看有没有能帮别
人能解决问题.也是回报社会了,哈哈.

5 楼

dk_kb_dup_adlGazeTalk_Author等类型声明:
class dk_kb_dup_adlGazeTalk_Author : public TRemotable {
private:
  int             FauthorID;
  WideString      Ffacts;
  int             FbirthYear;
  int             FdeathYear;
  int             FperiodID;
public:

__published:
  __property int          authorID = { read=FauthorID, write=FauthorID };
  __property WideString      facts = { read=Ffacts, write=Ffacts };
  __property int         birthYear = { read=FbirthYear, write=FbirthYear };
  __property int         deathYear = { read=FdeathYear, write=FdeathYear };
  __property int          periodID = { read=FperiodID, write=FperiodID };
};

6 楼

问题解决了.是BCB生成的代码有问题....

class  dk_kb_dup_adlGazeTalk_Author;

typedef DynamicArray<dk_kb_dup_adlGazeTalk_Author> ArrayOfdk_kb_dup_adlGazeTalk_Author;

应该是.
typedef DynamicArray<dk_kb_dup_adlGazeTalk_Author*> ArrayOfdk_kb_dup_adlGazeTalk_Author;

7 楼

>>CSQCPU:SOAP调用的参数和返回参数类型是限制的,只能使用部分的类对象,
>>不支持全部类对象。

不过还是很想知道,如何让DynamicArray支持全部类对象,欢迎继续跟贴...

我来回复

您尚未登录,请登录后再回复。点此登录或注册