Erlang/OTP Forums

Author Message

<  User Contributions  ~  erlsoap -- again :)

datacompboy
Posted: Thu Sep 21, 2006 3:05 am Reply with quote
User Joined: 21 Sep 2006 Posts: 69 Location: Novosibirsk, Russia
Here attached a new version of erlsoap (0.4.3) that uses erlsom for schema parse and generation.

It contains no documentation still, but have two samples, that describes everything :)

Demo1: client-server from original erlsom. Schema was changed to simple XSD form.

* Go to demo subdirectory, run erlang with erlsom and erlsoap in libpath, then
Code:
sms_demo:start(),
sms_demo:send_sms_local("test"),
sms_demo:send_sms_local_multi(["test1", "test2"]),
get_status_local("some_id").


demo/sms_demo.xsd -- contains XSD for service structures.
I have deprecated original schema used in sms_demo of 0.3 version, since it was too complicated (two namespaces... etc) and I have unable to write XSD for it :)

Demo2 just client to existing ASP.NET server.
Look into directory janus/
Register at rsdn.ru on forums, and do
Code:
janus:start().
janus:get_forum_list("username","password").


Planned TODO: parse WSDL, and build automated router that receive answer as plain lists / lists of lists and build correct records according to <message>'s.


Last edited by datacompboy on Mon Oct 02, 2006 4:32 am; edited 6 times in total


erlsoap-0.4.3.zip
 Description:
erlsoap 0.4.3 (01-oct-2006)

Download
 Filename:  erlsoap-0.4.3.zip
 Filesize:  64.67 KB
 Downloaded:  2612 Time(s)


_________________
--- suicide proc near\n call death\n suicide endp
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number
dmitriid
Posted: Thu Sep 21, 2006 8:01 am Reply with quote
User Joined: 17 Aug 2006 Posts: 213
Nice! So far looks much simpler than the previous version (haven't tested it yet, though)
View user's profile Send private message
datacompboy
Posted: Thu Sep 21, 2006 8:09 am Reply with quote
User Joined: 21 Sep 2006 Posts: 69 Location: Novosibirsk, Russia
dmitriid wrote:
Nice! So far looks much simpler than the previous version (haven't tested it yet, though)


version 0.3 needs lot of dance to make it works :)

_________________
--- suicide proc near\n call death\n suicide endp
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number
dmitriid
Posted: Thu Sep 21, 2006 8:22 am Reply with quote
User Joined: 17 Aug 2006 Posts: 213
Hi! Could you please add an example of a client-only application of erlsoap?

Such as http://www.webservicex.net/WS/WSDetails.aspx?WSID=64&CATID=12, for example

Thank you
View user's profile Send private message
datacompboy
Posted: Thu Sep 21, 2006 9:03 am Reply with quote
User Joined: 21 Sep 2006 Posts: 69 Location: Novosibirsk, Russia
dmitriid wrote:
Hi! Could you please add an example of a client-only application of erlsoap?


No, I will not do, but can describe sequence of what you should do :)
And if you will do that, post here result :)

So, your should do:
1. Download WSDL of service needed (service.wsdl)
2. Extract contents of <types>...</types> into separate file (service.xsd) (without <types> tag itself)
3. erlsom:write_hrl("service.xsd", "service.hrl").
-- And write your client:
4. define URL
Code:
-define(URL, "http://server/serviceport")

4. Prepare service definitions:
Code:
start()->
      soap_registry_server:start(),
      soap_registry_server:add_xsd(?URL, "service.xsd").

5. And write functions:
Code:
doRequest1(Args) ->
    case soapclient:invoke(?URL,
                      "Request1",
                      #'p:Request1'{'Args'=Args}) of
        {ok, Reply} -> Reply#'p:Request1_reply'{'ReplyCode'};
        {error, Error} -> {error, Error}
    end.


That's all! :)

Yes, in future, better to generate requester's in way of write_hrl -> like write_stub, so you only rename/change args... but that future. now -- you should just write callers by hands for all used services.

_________________
--- suicide proc near\n call death\n suicide endp
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number
dmitriid
Posted: Thu Sep 21, 2006 9:08 am Reply with quote
User Joined: 17 Aug 2006 Posts: 213
datacompboy wrote:
dmitriid wrote:
Hi! Could you please add an example of a client-only application of erlsoap?


No, I will not do, but can describe sequence of what you should do Smile
And if you will do that, post here result Smile


Yeeeha! Smile)

Thank you! I'm actually attempting to communicate (as painlessly as possible) with http://rsdn.ru/ws/JanusAT.asmx?WSDL So, if I have time today, I'll repeat these steps and post the result

The future looks bright! Smile)
View user's profile Send private message
dmitriid
Posted: Thu Sep 21, 2006 1:11 pm Reply with quote
User Joined: 17 Aug 2006 Posts: 213
Ok, I've promised to post my adventures.

After some discussion with Anton Fedorov, who released this version, here goes..

The WSDL I was working with is available here.


  1. Take everything between <wsdl:types></wsdl:types> tags, which should leave you with something like:
    Code:
    <s:schema elementFormDefault="qualified" targetNamespace="http://rsdn.ru/Janus/">
          <s:element name="GetTopicByMessage">
            <s:complexType>
               ...

  2. Important! Before you move forward take a long look at both the elements you've taken out and the <wsdl:definitions ...> tag in your original WSDL. You will need to add all namespaces used in your elements to your schema definition.

    My elements have things like:
    Code:

    <s:element name="Messages" type="tns:ArrayOfJanusMessageInfo"/>

    <s:element name="messageId" type="s:int"/>


    So, I will need the "tns" and the "s" namespaces from the original WSDL file. After adding the namespaces the beginning of my file now looks like this:
    Code:

    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://rsdn.ru/Janus/" targetNamespace="http://rsdn.ru/Janus/" >
    ...

  3. Important! Before you move forward you will need to find and remove all nillable="true" attributes.
  4. Save this schema as service.xsd
  5. Run erlsom to generate .hrl file that will contain records for every complex type in your .xsd file:
    Code:
    20> erlsom:write_hrl("service.xsd", "service.hrl").


    You are all set and ready to go

  6. Create two functions similar to these:
    Code:

    -define(URL, "http://rsdn.ru/ws/JanusAT.asmx").

    start() ->
       soap_registry_server:start(),
        soap_registry_server:add_xsd(?URL, "service.xsd").

    get_forum_list() ->
        http:set_options([{cookies, enabled}]),
        case soapclient:invoke(?URL,
                               "http://rsdn.ru/Janus/GetForumList",
                               #'p:GetForumList'{'forumRequest'=#'p:ForumRequest'{userName="dmitriid", password="***"}}) of
            {ok, Reply} -> Reply#'p:GetForumListResponse'.'GetForumListResult';
            {error, Error} -> {error, Error}
        end.


  7. Ok, you are all set and ready to go! Give it a try


P.S. erlsoap doesn't seem to work with this particular web-service, since it doesn't generate a request that corresponds to a 't' to the description. It may (and, probably, will) work for you, however.
View user's profile Send private message
datacompboy
Posted: Thu Sep 21, 2006 3:29 pm Reply with quote
User Joined: 21 Sep 2006 Posts: 69 Location: Novosibirsk, Russia
dmitriid wrote:
P.S. erlsoap doesn't seem to work with this particular web-service


Ok, have fixed:
* chaned envelope namespace from "env:" to "soap:" (need to look for other services, and if other service require not "soap:" -- do that configurable);
* for that service used soap-envelope.xsd with difference target namespace

So, get erlsoap-0.4.1 from thread start, and see Janus folder for sample.
So:
Code:
janus:start().
janus:get_forum_list("username","password").

_________________
--- suicide proc near\n call death\n suicide endp
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number
dmitriid
Posted: Sat Sep 23, 2006 11:31 am Reply with quote
User Joined: 17 Aug 2006 Posts: 213
Hi.

Here's a patch to soapclient.erl to use either ibrowse or inets. It now exports an additional function, invoke/4.

1. Using erlsoap with inets
-----------------------------

By default erlsoap uses inets. So, you can invoke erlsoap in two ways:
soapclient:invoke(URL, SOAPAction, Request).
soapclient:invoke(URL, SOAPAction, Request, {inets, [Options], [Headers]}).

Options and Headers are additional options that will be passed to
http:set_options/1 and http:request/4
as per Erlang documentation

2. Using erlsoap with ibrowse
-----------------------------

Since by default erlsoap uses inets, you must invoke erlsoap like this:
soapclient:invoke(URL, SOAPAction, Request, {ibrowse, [Options], [Headers]}).

Options and Headers are additional options that will be passed to
ibrowse:send_req/5
as per ibrowse documentation (available in ibrowse/doc)


You will need to place the patched soapclient file into your erlsoap/src directory and recompile it.

I'm not entirely sure I did everything correctly, so, please, do test it.



soapclient.erl
 Description:

Download
 Filename:  soapclient.erl
 Filesize:  6.82 KB
 Downloaded:  1701 Time(s)

View user's profile Send private message
tobbe
Posted: Wed Nov 08, 2006 9:04 am Reply with quote
User Joined: 19 Jan 2005 Posts: 274 Location: Stockholm, Sweden
I just started to take a look at erlsoap and downloaded the zip-file.
Unfortunately, the Makefiles make some annoying assumptions
about includefiles. Any chance of getting this fixed ?
Btw: are erlsoap avilable via CVS/SVN somewhere ?

--Tobbe
View user's profile Send private message Send e-mail Visit poster's website
datacompboy
Posted: Wed Nov 08, 2006 9:53 am Reply with quote
User Joined: 21 Sep 2006 Posts: 69 Location: Novosibirsk, Russia
tobbe wrote:
Unfortunately, the Makefiles make some annoying assumptions about includefiles.


Sorry, but Makefile there are not used by me, I'm use just build BAT files, and auto-make from erlide:)

I'll look on this soon.


No, there no cvs/svn, since I have just found some version erlsom, fixed it for my needs, and post here.

_________________
--- suicide proc near\n call death\n suicide endp
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number
tobbe
Posted: Wed Nov 08, 2006 10:03 am Reply with quote
User Joined: 19 Jan 2005 Posts: 274 Location: Stockholm, Sweden
Ok.

I have a WSDL and are following your description on how to get erlsom to generate an .hrl header file. However, it chokes on the following construct:

Code:

<xsd:element minOccurs="0" maxOccurs="1" name="HitListCompanyResult">
  <xsd:complexType mixed="true">
    <xsd:sequence>
      <xsd:any/>
    </xsd:sequence>
  </xsd:complexType>
</xsd:element>


...and displays the following error message: Mixed only supported for elements with maxOccurs > 1

I'm not good at this so if someone who is, could explain if my schema is wrong or if erlsom is at fault, it would be appreciated.

--Tobbe
View user's profile Send private message Send e-mail Visit poster's website
datacompboy
Posted: Wed Nov 08, 2006 10:11 am Reply with quote
User Joined: 21 Sep 2006 Posts: 69 Location: Novosibirsk, Russia
tobbe wrote:
...and displays the following error message: Mixed only supported for elements with maxOccurs > 1


Than an erlsom issue... Try to ask in erlsom thread, or just write mail Willem de Jong. I'm know nothing about that issue

_________________
--- suicide proc near\n call death\n suicide endp
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number
tobbe
Posted: Wed Nov 08, 2006 10:59 am Reply with quote
User Joined: 19 Jan 2005 Posts: 274 Location: Stockholm, Sweden
If we get permission from Erik Reitsma, then perhaps we could
create a google project for erlsoap. What do you think ?

--Tobbe
View user's profile Send private message Send e-mail Visit poster's website
datacompboy
Posted: Wed Nov 08, 2006 11:05 am Reply with quote
User Joined: 21 Sep 2006 Posts: 69 Location: Novosibirsk, Russia
tobbe wrote:
If we get permission from Erik Reitsma, then perhaps we could create a google project for erlsoap.


Why not? "Anything, that can be useful"

_________________
--- suicide proc near\n call death\n suicide endp
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum