Sending SOAP requests using libcurl as XML file

大憨熊 提交于 2019-12-23 01:52:35

问题


I'm trying to use libcurl to do a SOAP http post to a web service. I have the SOAP requests already formed in XML files which I generate. Now I need to transefer these XML files to the webservice. N.B. I'm pretty new to writing webservices (especially in C).

Is there a way do send the SOAP requests straight from the XML file using libcurl? Or do I have to read the contents into a string? I'm restricted to using the C programming language to complete the task.

I've been looking through documentation and different code snippets but I can't seem to locate anything to do the requested. This curl link does it through a string http://curl.haxx.se/libcurl/c/post-callback.html). FOr speed purposes I would greatly prefer to not have to pass to a string before sending it.


回答1:


you use curl_easy_setopt()? then you may want to take a look at CURLOP_WRITEFUNCTION and CURLOPT_WRITEDATA.




回答2:


The way I do this:
* Get TinyXML, load the file into a TiXmlDocument and use the TiXmlPrinter to get the XML file as string
* Set the value of the string in the body of the post request( also, set headers, but they are the same as HTTP standard headers)
* Take a look at curl_easy_setopt() for callback and other stuff (:

Good Luck (:



来源:https://stackoverflow.com/questions/4131946/sending-soap-requests-using-libcurl-as-xml-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!