Webservice soap request


#1

Hi,

I am trying to post a Soap xml request to a web server which accepts the invocation using the SOAP/HTTP POST binding.

Is it possible to do that using the juce::URL class? Any code guidelines how this could work?

Thanks
Kyriacos


#2

I’ve no idea how SOAP works… Is it just some xml that you pass in a http request? If so, that’d be easy enough to do with the URL class if you can generate the xml.


#3

Hi Jules,

Thanks for the reply.

I have managed to call the server but it replies that the content type is Content-Type: application/x-www-form-urlencoded

To do this call I need to have the different headers as the program below.

Do I add the headers correctly? When I put my headers the function is overiding the default headers?

Thanks!

String strHeaders = “Content-Type:text/xml;charset=utf-8\r\n”;
strHeaders += “Accept: text/xml /\r\n”;

juce::URL myServer(“http://server/Services”);
myServer.createInputStream(true,0,0,strHeaders,30000);
URL t = myServer.withPOSTData(sSoapIn);


#4

That looks right to me.


#5

Hi Jules,

I have put here the next lines of the program plus the output of the server.
Any ideas?

Thanks

Program:

String strHeaders = “Content-Type:text/xml;charset=utf-8\r\n”;
strHeaders += “Accept: text/xml /\r\n”;

juce::URL myServer(“http://server/Services”);
myServer.createInputStream(true,0,0,strHeaders,30000);
URL t = myServer.withPOSTData(sSoapIn);

juce::XmlElement* xmlRet = new XmlElement(“bla”);
xmlRet = t.readEntireXmlStream(true);
String jj = xmlRet->createDocument("",false,true,L"UTF-8",60);

Server return:

<?xml version="1.0" encoding="UTF-8"?>

<SOAP-ENV:Envelope xmlns:SOAP-ENV=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd=“http://www.w3.org/2001/XMLSchema”>
SOAP-ENV:Body
SOAP-ENV:Fault
SOAP-ENV:Protocol
Unsupported content type “application/x-www-form-urlencoded”, must be: “text/xml”.
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


#6

some time ago i wrote a XmlRpc class in JUCE using Curl (i needed more proxy options then the normal OS proxy stuff) maybe you can use that in some way, it uses my cURL class based on the curl library, but it worked for me.

http://code.google.com/p/edoapp/source/browse/#svn/trunk/src/Core/EdoXmlRpc


#7

[quote=“atom”]some time ago i wrote a XmlRpc class in JUCE using Curl (i needed more proxy options then the normal OS proxy stuff) maybe you can use that in some way, it uses my cURL class based on the curl library, but it worked for me.

http://code.google.com/p/edoapp/source/browse/#svn/trunk/src/Core/EdoXmlRpc[/quote]

Hi Atom,
Your class looks very nice, have you used it to call soap webservices? Do you have any example(s) how to use it?
Can it be used without the Curl library, I will prefer to use the min libs preferably juce only.

Thanks
Kyriacos


#8

Hi Jules,
I have changed the content type from the url.cpp file and now the server does not complain about the content type. I think you do not replace the headers??

Thanks
K.


#9

Not sure about the headers - the ones you supply get passed into the native http calls, and I’d expect the OS to use your header fields instead of the default, but I guess that’s not guaranteed…


#10

[quote=“Koull”][quote=“atom”]some time ago i wrote a XmlRpc class in JUCE using Curl (i needed more proxy options then the normal OS proxy stuff) maybe you can use that in some way, it uses my cURL class based on the curl library, but it worked for me.

http://code.google.com/p/edoapp/source/browse/#svn/trunk/src/Core/EdoXmlRpc[/quote]

Hi Atom,
Your class looks very nice, have you used it to call soap webservices? Do you have any example(s) how to use it?
Can it be used without the Curl library, I will prefer to use the min libs preferably juce only.

Thanks
Kyriacos[/quote]

it’s based on curl so it has to use it, it was more flexible then the URL class for this sort of thing and as JUCE it’s cross platform.
it’s using the XML-RPC standard so it won’t work with SOAP, but i guess it can be easily transformed to do SOAP requests (the idea is the same just the format is different)


#11

i’m actually using gSOAP ( http://www.cs.fsu.edu/~engelen/soap.html ) with juce and i’m pretty happy with it. It also features a tool that generate C++ code from a WSDL definition, useful to have C classes out of your web service with no hassle at all, and without writing code.


#12

Hi All,

I have succeded calling the soap web services with the following function but it works only the first time i call the program.
The second time it crashes the application in the line with the readEntireXmlStream statement

Any help?

Thanks
Kyriacos

String CXmlWebServices::sendXmlRequest(String XmlInput, String WsUrl)
{

String strHeaders ="Accept: text/xml */*\r\n";
strHeaders += "Content-Type: text/xml;charset=utf-8\r\n";
strHeaders += "Accept-Language: en-us\r\n";

juce::URL myXmlServer(WsUrl);

myXmlServer.createInputStream(true,0,0,strHeaders,30000);

URL myURL = myXmlServer.withPOSTData(XmlInput);

juce::XmlElement xmlRet("Temp");
xmlRet = *myURL.readEntireXmlStream(true); //crashes here 2nd time of call

String sXmlRet =xmlRet.createDocument("",false,true,L"UTF-8",60);

return sXmlRet;

}


#13

Hi,

I am using gsoap but for some IBM java ws servers it just does not work.

Thanks


#14

You probably need to learn how to use your debugger (and likely, you shouldn’t dereference a pointer without checking for NULL before)

Gsoap works, but sometime it’s a monster for nothing. If you only need to do few SOAP requests, you are probably better with writing SOAP template XML files and use Juce’s XML engine to parse the result


#15

Hi All,

I have done it to work ok.

The problem was with the createInputStream function, now I do not use it.

For Soap and xml ws to work some mods are needed in the URL class, if anybody is interested I can give him the code.

Thanks
Kyriacos


#16

Hello,

Can you post your code example ?
Thanks !


#17

Hi Kyriacos,

I know this is a very old thread, but anyway I would like to ask you how you did in implementing a SOAP client in JUCE.

I am trying to find the best/easiest way to access a WCF service from a JUCE client, and I have been through quite a few implementations out there.

I have of course looked at gSOAP but one problem is the licensing, and also, I would like to statically link my application to one exe file.

Any input would be highly appreciated!

Thanks a lot in advance.

/Anders


#18

Hi,

I do not have the code since now I am using the CURL library. From what I remember I have changed the headers in the main juce::url class; it was a minimal change, later on I have changed to CURL since it has support for https, ftps etc. I do not know the current status of the juce url class but at the time the CURL library had complete functionality for any type of http/ftp calls I needed.

Regards
K.