[erlang-questions] Best Erlang approach for sending and parsing XML via HTTP

100 views
Skip to first unread message

Thomas Elsgaard

unread,
Nov 17, 2012, 12:27:46 PM11/17/12
to erlang-q...@erlang.org
Hi list

I need to interface with an SOAP service, and i would like to keep it as simple as possible, so basically i would like just to send the XML via HTTP and parse the response, what is the best approach for this with Erlang?

Could i use httpc, or should i go for the SOAP client via Yaws? 

The request i need to send is:

-------------------------
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header />
    <Body>
        <ns:Login xmlns:ns="http://schemas.ericsson.com/cai3g1.1/">
            <ns:userId>"xxxx"</ns:userId>
            <ns:pwd>"xxxx"</ns:pwd>
        </ns:Login>
    </Body>
</soapenv:Envelope> 
-------------------------

And i need to get the sessionId in the response:

-------------------------
<?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Header></SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <ns3:LoginResponse>
            <ns3:sessionId>84c3646484c36464000000001353168328092</ns3:sessionId>
            <ns3:baseSequenceId>5584289115023516944</ns3:baseSequenceId>
        </ns3:LoginResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
-------------------------

Dmitry Kolesnikov

unread,
Nov 17, 2012, 12:32:26 PM11/17/12
to Thomas Elsgaard, erlang-q...@erlang.org
Hello,

Yes, simples solution is httpc + xmerl for xml parsing. All components are otp built-in. 
but ready made soap client might give you some advantage on envelope parsing.

- Dmitry

_______________________________________________
erlang-questions mailing list
erlang-q...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

Robert Raschke

unread,
Nov 17, 2012, 1:19:54 PM11/17/12
to Thomas Elsgaard, erlang-q...@erlang.org

Hi Thomas,

if all you really need, is that one specific call, then rolling your own simple solution with httpc and xmerl is the quickest route. And xmerl_xs is very handy for retrieving the result value.

Only when you get to the stage of dealing with multiple SOAP operations and more complicated XML structures does something more "integrated" become viable.

Robby

Thomas Elsgaard

unread,
Nov 17, 2012, 5:13:05 PM11/17/12
to erlang-q...@erlang.org

Hi Thomas,

if all you really need, is that one specific call, then rolling your own simple solution with httpc and xmerl is the quickest route. And xmerl_xs is very handy for retrieving the result value.

Only when you get to the stage of dealing with multiple SOAP operations and more complicated XML structures does something more "integrated" become viable.

Robby


Thanks!! It was very easy to roll my own with httpc and xmerl, and it works perfectly.

///Thomas

 
Reply all
Reply to author
Forward
0 new messages