+1
Answered

Httpmethod and text template to call web services

sstava 12 ár síðan updated by John Heryer 12 ár síðan 1
Are there details for the httpmethod attribute for the datasource tag? The documentation just has a "?" :)

Also, an example of using httpmethod in combination with texttemplate to call a webservice would be great!
The http method attribute is used to change the request type to the remote server. The options are get or post.

Text templates are very powerful. All rarewire bracketed objects ( eg. [var:stuff] ) are evaluated when you access the 'content' property of the TT ( [template:mycontent.content] )

With the use of the <httpheader> <datasource> <textemplate> , this simple can be extended to a full soap service client.

Below is the foundation of how it works:


<wire>
<datasources>
<datasource name="jsonservice" source="" query="/" providertype="json" querycomplete="response" httpmethod="post"/>
</datasources>

<main>
<texttemplate name="mycontent"><![CDATA[{ "firstname" : "john" , "lastname":"Smith" }]]></texttemplate>
</main>

<actions>
<action name="start" oninit="yes">
<sync>

<assign property="datasource:jsonservice.postContent" value="[template:mycontent.content]" />
<assign property="datasourcejsonservice.source" value="http://myserver.com/name" />

</sync>
</action>

<action name="response">
<alert message="[datasource:jsonservice.1.status]"/>
</action>
</actions>
</wire>


If you have a server you have setup and can verify the requests coming to it, we can help you put together a working example. Feel free to send Ian the details and we help you get a prototype running.