如何编写一个gsoap restful C++/Solaris客户端,它应该使用流媒体将文档(xsd__base64Binary)发送到webservice?
我们尝试编写一个没有流式传输的gsoap restful客户端,它工作正常.我们使用gsoap生成了一个请求xml(serialization-soap_begin_send( - ),soap_serialize( - ),soap_put( - ),soap_end_send( - )),然后使用了soap_post_connect(---),soap_send(---) ,soap_end_send(---)发送请求.
我们在gsoap客户端使用MTOM进行流式处理并且工作正常.是否可以在gsoap restful客户端中流式传输文档?我们可以在宁静的情况下使用MTOM吗?如果是,请您告诉我们,我应该使用什么gsoap函数进行序列化,然后发送该xml请求?如果您有任何示例代码,请分享.
我需要在C++中使用gsoap库,我需要使用https.文档说明了如何在C中使用HTTPS,但在C++中却没有(http://www.cs.fsu.edu/~engelen/soapdoc2.html#tth_sEc19.20).特别是,我在soap_ssl_init();功能上有编译错误.我查了/ usr/lib/libgsoap*文件,找到了ligsoapssl ++.一个文件并链接到它.这个错误消失了,但我明白了error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed.这意味着我需要调用soap_ssl_client_contextfunc,但是在C++中没有生成类.我该怎么办?
UPD:我自己解决了这个问题.但它是古怪的,非常古怪的方式.gSOAP生成继承自struct soap的C++类,它包含以下attrs:
BIO *bio;
SSL *ssl;
SSL_CTX *ctx;
unsigned short ssl_flags;
const char *keyfile;
const char *password;
const char *dhfile;
const char *cafile;
const char *capath;
const char *crlfile;
const char *randfile;
SSL_SESSION *session;
Run Code Online (Sandbox Code Playgroud)
所以我们可以自己在OpenSSL库中设置必要的attrs(flags,params).在简单的情况下,它足以调用soap_ssl_init()一次并设置ssl_flags = SOAP_SSL_NO_AUTHENTICATION.这个对我有用.如果有人知道更好的方式,我会很高兴看到.
我们如何在C++/Linux中为Gsoap实现WSSE插件?此链接不提供所有信息.
问题是我必须包含在我的WSDL生成的头文件中,使它与wsse兼容,以便soapcpp2 header.h生成足够的代码,以便我可以成功编译wsseapi.c?
另外,如果可能的话请提供实现wsse插件的工作示例代码(仅限C++,没有C plz)?
我有应用程序.在这里,我从WSDL生成客户端服务.现在一些功能正常.但有些是错的.
它是WSDL的一部分
<xs:complexType name="TStartInfoCalcZoneViewForArea">
<xs:sequence>
<xs:element minOccurs="0" name="ID" type="xs:int"/>
<xs:element minOccurs="0" name="startFreq" type="xs:double"/>
<xs:element minOccurs="0" name="endFreq" type="xs:double"/>
<xs:element minOccurs="0" name="startTime" type="xs:string"/>
Run Code Online (Sandbox Code Playgroud)
它是c#的一部分
public partial class TStartInfoCalcZoneViewForArea
{
private int idField;
private bool idFieldSpecified;
private double startFreqField;
private bool startFreqFieldSpecified;
private double endFreqField;
private bool endFreqFieldSpecified;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order=0)]
public int ID
{
get
{
return this.idField;
}
set
{
this.idField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool IDSpecified
{
get
{
return this.idFieldSpecified;
}
set
{
this.idFieldSpecified = …Run Code Online (Sandbox Code Playgroud) 我是GSOAP的新手,所以可能会遗漏一些明显的东西.但我真的无法在GSOAP文档中找到它的解决方案.
我需要知道,如何在GSOAP中静默忽略我的xml中的未知节点而不影响其他节点.
例如:我有下课
class gsoap_ex
{
int foo;
char bar;
}
Run Code Online (Sandbox Code Playgroud)
以下XML:
<gsoap_ex>
<foo>foo_value</foo>
<unknown>unknown_value</unknown>
<bar>bar_value</bar>
</gsoap_ex>
Run Code Online (Sandbox Code Playgroud)
截至目前,我的gsoap解析xml直到它到达未知节点,之后它返回而不进一步解析它.
print_after_parsing(gsoap_ex *obj)
{
cout<<obj->foo;
cout<<obj->bar;
}
Run Code Online (Sandbox Code Playgroud)
所以在我的上面的函数中它显示了foo的值,但是没有设置bar的值.
我该如何实现?
gsoap及其工具wsdl2h和soapcpp2为我提供了一个包含以下内容的soapStub.h文件:
class SOAP_CMAC ns2__SOAPKunden
{
public:
std::string *adresszusatz;
// ...
public:
virtual int soap_type() const { return 7; }
// ...
ns2__SOAPKunden() : adresszusatz(NULL), x(NULL) { } // left out all member init.
virtual ~ns2__SOAPKunden() { }
};
Run Code Online (Sandbox Code Playgroud)
我从一个小应用程序开始,使用该类用informix DB中的数据填充对象.
但要成功编译我必须放弃所有的虚拟东西 - 我发现很多关于这个错误的帖子和在子类中使用虚拟成员 - 否则我得到
main.o: In function `ns2__SOAPKunden::ns2__SOAPKunden()':
main.cpp:(.text._ZN15ns2__SOAPKundenC1Ev[ns2__SOAPKunden::ns2__SOAPKunden()]+0xf): undefined reference to `vtable for ns2__SOAPKunden'
main.o: In function `ns2__SOAPKunden::~ns2__SOAPKunden()':
main.cpp:(.text._ZN15ns2__SOAPKundenD1Ev[ns2__SOAPKunden::~ns2__SOAPKunden()]+0x13): undefined reference to `vtable for ns2__SOAPKunden'
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
我承认经过多年的脚本编写后,我很难理解C++代码......我想问一下下一步要做什么的建议.我的班级没有派生类,例如让我惊讶的是什么.
我在工作ubuntu,c++代码.
使用gsoap和我已经成功地成功创建,
和文件.当我和他们的文件我收到以下错误:wsdl2h -o header.h
http://link1 http://link2.h.cpp.xml#include proxy1.h#include proxy2.hnmsp
redefinition of "Namespace namespaces[]', previously defines here .
Run Code Online (Sandbox Code Playgroud)
如何解决这个错误?当我使用:我stdsoap2 -i -C -Iimport header.h不能为每个网址指定不同的命名空间吗?我想提一下,stdsoap.cpp当我编译代码时使用它.在stdsoap名称空间中称为名称空间.
谢谢
通过将XML文档加载到C++类,修改数据并将其序列化为XML,我一直在玩gSOAP XML数据绑定.
这是XML-library.xml的片段:
<?xml version="1.0" encoding="UTF-8"?>
<gt:Library xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:gt="http://www.bk.com/gSOAP/test">
<gt:Books>
<gt:Book isbn="0132350882" author="Robert C. Martin" title="Clean Code">
<gt:CopiesAvailable>2</gt:CopiesAvailable>
</gt:Book>
<gt:Book isbn="020161622X" author="Andrew Hunt" title="The Pragmatic Programmer">
<gt:CopiesAvailable>0</gt:CopiesAvailable>
</gt:Book>
<gt:Book isbn="0201633612" author="Erich Gamma" title="Design patterns">
<gt:CopiesAvailable>1</gt:CopiesAvailable>
</gt:Book>
</gt:Books>
...
</gt:Library>
Run Code Online (Sandbox Code Playgroud)
以下代码将XML加载到对象中,修改对象并将其序列化为XML.请注意,XML是通过文件流从文件加载的,并且要添加的数据是通过stdin(cin)从用户获得的.
main.cpp中:
#include "soapH.h"
#include "gt.nsmap"
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
using std::cin;
using std::cout;
using std::endl;
using std::ifstream;
using std::ofstream;
using std::fstream;
using std::string;
using std::stringstream;
void DisplayAllBooks(const _gt__Library& library)
{
cout << "\n\nDisplaying …Run Code Online (Sandbox Code Playgroud) 我有一个WSDL文件,我需要从它生成一个c ++ Web服务代码.我正在使用的工具链是gSOAP.
问题是生成的服务器类,每个操作都有一个带参数的函数,char*而不是类似ns2__something结构的东西.如何强制gSOAP生成XML/C或XML/C++绑定(根据我对gSOAP文档的理解,它应该这样做[?])
WSDL文件:
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="swus"
targetNamespace="swus.wsdl"
xmlns:tns="swus.wsdl"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ns="urn:swus"
xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:MIME="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:DIME="http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/"
xmlns:WSDL="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<schema targetNamespace="urn:swus"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ns="urn:swus"
xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="unqualified"
attributeFormDefault="unqualified">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<element name="addRequestElement">
<complexType>
<sequence>
<element name="a" type="xsd:double"></xsd:element>
<element name="b" type="xsd:double"></xsd:element>
</sequence>
</complexType>
</element>
<element name="addResponseElement">
<complexType>
<sequence>
<element name="result" type="xsd:double"></xsd:element>
</sequence>
</complexType>
</element>
</schema>
</types>
<message name="addRequest">
<part name="parameters" element="addRequestElement"/>
</message>
<message name="addResponse">
<part name="result" element="addResponseElement"/>
</message>
<portType name="calcPortType"> …Run Code Online (Sandbox Code Playgroud) 我们在同一个项目中编译了六个WSDL,由于硬件的限制,我们只能打开一个端口进行监听.
为此,我们选择本" gSOAP手册"第7.2.8章如何链接C++服务器类以接受同一端口上的消息所描述的方法.
但是,在使用此方法时,我们会遇到许多严重问题:
1.如果大量请求同时到达,那么有时soap_begin_serve报告错误,错误= -1,套接字在SOAP服务器建立后立即关闭
2.如果我们在soap_free_stream()之后调用xxx.destory(),那么soap_accept()将报告错误的文件描述符错误而不再工作(已解决)
有人知道上述现象的原因是什么?怎么解决?
我们的代码非常接近示例,除了一些更改,请参阅下面的部分.
//server thread
Abc::soapABCService server; // generated with soapcpp2 -i -x -n -QAbc
server.bind(NULL, 12345, 100);
server.soap_mode = SOAP_KEEP_ALIVE | SOAP_UTF_CSTRING;
server.recv_timeout = server.send_timeout = 60;
while (true)
{
server.accept();
...
pthread_create(&pid, NULL, handle_new_request, server.copy());
} // while(true)
// work thread - the thread function
void *handle_new_request(void* arg)
{
// generated with soapcpp2 -i -x -n -QAbc
Abc::soapABCService *abc = (Abc::soapABCService*)arg;
Uvw::soapUVWService uvw; // generated with soapcpp2 …Run Code Online (Sandbox Code Playgroud)