简体   繁体   English

使用gSOAP独立服务器发布wsdl?

[英]publishing wsdl with gSOAP stand-alone server?

Now, I developed a gSOAP stand-alone server on 8080 port and it's working for SOAP RPC. 现在,我在8080端口上开发了一个gSOAP独立服务器,它正在为SOAP RPC工作。

But I want to return wsdl content of a wsdl file in my file system when clients request for getting wsdl on the 8080 port. 但我想返回WSDL文件的WSDL内容在我的文件系统,当客户端请求的8080端口上获取WSDL。

what I can do to return wsdl to clients? 我能做些什么来将wsdl归还给客户?

I used xd tool to generate a embbed version of my wsdl and store it a wsdl.h file with this command line (I`m doing this in my CMakeList.txt): 我使用xd工具生成我的wsdl的嵌入版本,并使用此命令行将其存储为wsdl.h文件(我在我的CMakeList.txt中执行此操作):

${GSOAP_ROOT_DIR}/bin/win32/xd -dwsdl ${CMAKE_CURRENT_BINARY_DIR}/${SOAP_NAME_SERVICE}.wsdl > ${CMAKE_CURRENT_BINARY_DIR}/wsdl.h

After that, I implemented this function, that can be better to lead with parameters in GET request: 之后,我实现了这个功能,最好在GET请求中引导参数:

int http_get(struct soap *soap)
{
  soap_response(soap, SOAP_HTML); // HTTP response header with text/html
  soap_send(soap, (const char*)wsdl);
  soap_end_send(soap);
  return SOAP_OK;
}

So, I configure this function to lead with all GET commands received by gSoap: 因此,我将此函数配置为使用gSoap接收的所有GET命令:

.
.
.
struct soap soap;
soap_init(&soap);
soap.fget = http_get;
.
.
.

Then, when your server receive a HTTP/GET request, your function will be called and send the wsdl file. 然后,当您的服务器收到HTTP / GET请求时,将调用您的函数并发送wsdl文件。 If you want, you can read WSDL file at runtime and send in soap_send() instead to embbed WSDL in your code like I did. 如果需要,您可以在运行时读取WSDL文件并发送soap_send(),而不是像我一样在您的代码中嵌入WSDL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM