gSOAP是否支持复杂类型的参数? [英] does gSOAP support parameters of complex type?

查看:172
本文介绍了gSOAP是否支持复杂类型的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

gSOAP是否支持复杂类型的参数?

如果是这样,您如何从C ++客户端实例化它们?有人可以给我举个例子吗?

我获得了从C ++ 5.0旧版应用程序调用的Web服务的WSDL.我遵循了CodeProject的CurrencyConverter示例,该示例非常适合我.但是使用我们自己的WSDL,由于参数的复杂类型,我遇到了一个问题.输入参数类型的实例化似乎没有实例化包含输入字符串的类组件.因此,当我尝试以这种方式为其分配数据时,

(myServiceCallNumber-> processServiceCallNumber)-> serviceCallNumber = sInput;

,它崩溃了.我尝试了几件事,包括"processServiceCallNumber"子组件的附加实例化,但我的尝试均未成功.我需要尽快完成此操作,因此感谢您提出任何想法.

我可以发送一部分代码,或者发送WSDL(如果有人在乎的话).

谢谢!

------------- OP更新(作为解决方案发布)----
我糊涂了.我从中了解到的CurrencyConverter示例为每个参数调用了soap_instantiate,它说这是必要的.但是,当我查看这些其他示例时,我根本看不到任何对soap_instantiate的调用.所以也许我应该做一些完全不同的事情??

我了解我的输入参数的结构.它是此类的一个对象:

Does gSOAP support parameters of complex type?

And if so, how do you instantiate them from the C++ client? Can someone point me to an example?

I was given WSDL for a web service that I need to call from a C++ 5.0 legacy application. I followed the CurrencyConverter example from CodeProject, which worked perfectly for me. But using our own WSDL, I''m running into an issue due to the complex type of the parameters. The instantiate for the type of the input parameter doesn''t seem to instantiate the class component that contains the input string. So when I try to assign data to it in this fashion

(myServiceCallNumber->processServiceCallNumber)->serviceCallNumber = sInput;

,it crashes. I''ve tried several things, including an additonal instantiate of the ''processServiceCallNumber'' sub-component, but none of my attempts have been successful. I need to have this done ASAP, so any ideas appreciated.

I can send a chunk of my code, or the WSDL if anyone cares to see it.

Thanks!

-------------OP update (posted as solution)----
I''m confused. The CurrencyConverter example I learned from made a call to soap_instantiate for each parameter, and it said that was necessary. But when I''m looking at these other examples, I never see any call to soap_instantiate at all. So maybe I should be doing something completely different???

I understand the structure of my input parameter. It is an object of this class:

class SOAP_CMAC ns1__processServiceCallNumber
{
public:
class ns1__validateServiceCallNumberInput *processServiceCallNumber; /* optional element of type ns1:validateServiceCallNumberInput */
struct soap *soap; /* transient */
public:
virtual int soap_type() const { return 6; } /* = unique id SOAP_TYPE_ns1__processServiceCallNumber */
virtual void soap_default(struct soap*);
virtual void soap_serialize(struct soap*) const;
virtual int soap_put(struct soap*, const char*, const char*) const;
virtual int soap_out(struct soap*, const char*, int, const char*) const;
virtual void *soap_get(struct soap*, const char*, const char*);
virtual void *soap_in(struct soap*, const char*, const char*);
ns1__processServiceCallNumber() : processServiceCallNumber(NULL), soap(NULL) { }
virtual ~ns1__processServiceCallNumber() { }
};


并且ns1__validateServiceCallNumberInput的定义如下:


and ns1__validateServiceCallNumberInput is defined like this:

class SOAP_CMAC ns1__validateServiceCallNumberInput
{
public:
char *serviceCallNumber; /* optional element of type xsd:string */
struct soap *soap; /* transient */
public:
virtual int soap_type() const { return 7; } /* = unique id SOAP_TYPE_ns1__validateServiceCallNumberInput */
virtual void soap_default(struct soap*);
virtual void soap_serialize(struct soap*) const;
virtual int soap_put(struct soap*, const char*, const char*) const;
virtual int soap_out(struct soap*, const char*, int, const char*) const;
virtual void *soap_get(struct soap*, const char*, const char*);
virtual void *soap_in(struct soap*, const char*, const char*);
ns1__validateServiceCallNumberInput() : serviceCallNumber(NULL), soap(NULL) { }
virtual ~ns1__validateServiceCallNumberInput() { }
};


所以我需要在(myServiceCallNumber->processServiceCallNumber)->serviceCallNumber = sInput;
中传递我的serviceCallNumber输入字符串

但是当我尝试设置该值时,按如下所示实例化了输入参数后,它崩溃了,因为内部组件(即ns1__validateServiceCallNumberInput)似乎没有被实例化.因此,我认为对于这种类型的复杂"参数,我需要对实例化做一些不同的事情.我一直在看很多例子...我会继续看,但是如果有人可以指出一个特定的例子,或者给我一些不同的方向,那将是很棒的.


So I need to pass my serviceCallNumber input string in (myServiceCallNumber->processServiceCallNumber)->serviceCallNumber = sInput;


But when I try to set that value, after having instantiated the input parameter as below, it crashes because that inner component (i.e., ns1__validateServiceCallNumberInput) doesn''t seem to be instantiated. So, I think for this type of ''complex'' parameter, I need to do something different for the instantiation. I''ve been looking at lots of examples... I''ll keep looking, but if someone can point to a particular example, or give me some different direction,that would be great.

//instantiate input paramter
ns1__processServiceCallNumber* myServiceCallNumber;
size_t *pServiceCallNumberSize = new size_t;
*pServiceCallNumberSize = sizeof(ns1__processServiceCallNumber);
myServiceCallNumber = (ns1__processServiceCallNumber*) soap_instantiate(validateServiceCallNumberBinding_->soap, SOAP_TYPE_ns1__processServiceCallNumber,"","",pServiceCallNumberSize);
delete pServiceCallNumberSize;
 
//call web service, after also instantiating response parameter, not shown...
iRet = validateServiceCallNumberBinding_->__ns1__processServiceCallNumber(myServiceCallNumber, myServiceCallNumberResponse);

推荐答案

什么是复杂类型? ...在结构上一样?是的,您应该看到它们是在WSDL本身中定义的(尽管其格式有些奇怪).阅读作者在其网站中提供的文档 [
What do you mean complex type? ... as in structures? yes, you should see them defined in the WSDL itself (although its in a somewhat odd format). Read the documentation provided by the authors in their website[^]. It actually provides quite a bit of information and examples. One of the products of the gSOAP compilation will be a document with all structure/class definitions that you''ll be able to use in your C++ code.


这篇关于gSOAP是否支持复杂类型的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆