| View previous topic :: View next topic |
| Author |
Message |
Jeremy Howard The "e" in e-mail
Joined: 09 Apr 2002 Posts: 325 Location: Melbourne
|
Posted: Sun Aug 24, 2003 5:01 am Post subject: First FastMail.FM SOAP API test available! |
|
|
[i]Update: The API described below has now been updated. Please read this thread instead, which describes the new API: http://www.fastcheck.org/phpbb2/viewtopic.php?t=332]/i]
Perl code for the SOAP::MessagingEngine client module and a simple test client is now available here: http://jhoward.fastmail.fm/fastcheck/testsoapfolders.tgz
For experienced Perl programmers you should find it easy to use - stick MessagingEngine.pm in a folder called 'SOAP' and run the .pl script with the parameters you'll see it requires.
If someone gets it working, please post more details instructions here - I'm a bit busy right now myself...
Have fun!
Anyone interested in creating equivalent classes and test in Ruby, Python, Java, C++, etc - please go ahead and do so, and upload your code!
Last edited by Jeremy Howard on Sun Apr 04, 2004 8:02 am; edited 2 times in total |
|
| Back to top |
|
 |
rthomas
Joined: 25 Aug 2003 Posts: 11 Location: France, Lille
|
Posted: Mon Aug 25, 2003 9:48 am Post subject: Whet is the URI ? |
|
|
| Quote: | | $Soap->uri("$HostName/MessagingEngine"); |
Hello Jeremy
I'm looking after the HostName for one hour now and I can't find this info in the forum.
What is the HostName ?
I'm planning to consume SOAP using Microsoft .NET, and looking for synchronizing the address book with Outlook and PocketPC.
Cheer
Remi |
|
| Back to top |
|
 |
stuarteggerton
Joined: 15 May 2002 Posts: 10
|
Posted: Mon Aug 25, 2003 9:58 am Post subject: |
|
|
rthomas, Try www.fastmail.fm
I have had some success but the compose screen is the only URL I can get back..
Jeremy, Delphi will setup a wrapper for all the methods automatically if there is a wsdl file. I know URL_CreateURL and CreateSession are a couple of the methods but I can't figure out the complete list yet....Good work though! I am pretty excited about writing a web services/SOAP based Delphi client to fastmail...
cheers
Stuart |
|
| Back to top |
|
 |
rthomas
Joined: 25 Aug 2003 Posts: 11 Location: France, Lille
|
Posted: Mon Aug 25, 2003 10:25 am Post subject: Automatic WSDL file generation |
|
|
Giving us the interfaces available I can produce the WSDL files in a few click, then you can use this as a template and manually modify them.
Remi |
|
| Back to top |
|
 |
Jeremy Howard The "e" in e-mail
Joined: 09 Apr 2002 Posts: 325 Location: Melbourne
|
Posted: Tue Aug 26, 2003 1:06 am Post subject: |
|
|
| stuarteggerton wrote: | rthomas, Try www.fastmail.fm
Jeremy, Delphi will setup a wrapper for all the methods automatically if there is a wsdl file. I know URL_CreateURL and CreateSession are a couple of the methods but I can't figure out the complete list yet....Good work though! I am pretty excited about writing a web services/SOAP based Delphi client to fastmail... | Great! Can you post your code? Have you got the authentication working well?
I do plan to create a WSDL file at some stage, but obviously the authentication stuff will have to be ported to each language manually.
Note in the .pl test script these lines: | Code: | $Session->SetNamespace('AccountInfo');
my $FolderInfo = $Session->GetFolderList(); | Since 'GetFolderList' doesn't contain a '_', SOAP::MessagingEngine automatically turns it into 'AccountInfo_GetFolderList', since this is the current namespace. If you don't create a SOAP class in Delphi that can use namespaces like this, you'll need to always call MessagingEngine methods as NameSpace_MethodName (as I showed in the .pl script with URL_CreateURL.)
At this stage you can only get URLs to Compose and Mailbox. Let me know what others you'd like and I'll add them.
Once you've got all these features working, let me know, and I'll try and find the time to create test scripts for some other features. Please post info on what you do to get things working in your language, and anything else you find. And do ask if you need anything explained. |
|
| Back to top |
|
 |
ivec
Joined: 22 May 2002 Posts: 26 Location: Dublin, Ireland
|
Posted: Tue Aug 26, 2003 7:38 am Post subject: |
|
|
| Quote: | | At this stage you can only get URLs to Compose and Mailbox. Let me know what others you'd like and I'll add them. |
Jeremy, would it be possible to add fastmails archiving functionality to fastservices at some point? It would need to accept a list of message UIDs to archive and return a zipped file with specified messages from the currently selected mailbox. |
|
| Back to top |
|
 |
rthomas
Joined: 25 Aug 2003 Posts: 11 Location: France, Lille
|
Posted: Tue Aug 26, 2003 3:15 pm Post subject: First .NET Tests |
|
|
Hi,
I have several question about this version of SOAP::Lite running.
The context
Microsoft .NET is a very advanced platform to produce or consume web services (or SOAP). The framework (= all the class library) contain a SoapHttpClientProtocol class for manually consume a SOAP interface. With a WSDL file it make the wrapper automatically.
The problem
I succed to send a correct SOAP frame but get an error in the answer
I post
| Code: | POST /soap/ HTTP/1.1
VsDebuggerCausalityData: uIDPoybrrJSp2Z1Fgj1miJ54LEoAAAAAjyD9Bt5WwEO1CDkmJV7jb1N/VMz4ACRKlvIkXrAcbFsACAAA
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 1.2.30703.4)
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://www.fastmail.fm/SOAP/MessagingEngine#CreateSession"
Host: localhost:8080
Content-Length: 579
Expect: 100-continue
Connection: Keep-Alive
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="MessagingEngine" xmlns:types="MessagingEngine/encodedTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><q1:CreateSession xmlns:q1="http://www.fastmail.fm/SOAP/MessagingEngine"><UserName xsi:type="xsd:string">xtware</UserName></q1:CreateSession></soap:Body></soap:Envelope> |
And I get the error
| Code: | HTTP/1.1 100 Continue
HTTP/1.1 500 Internal Server Error
Date: Tue, 26 Aug 2003 14:58:12 GMT
Server: Apache/1.3.27 (Unix) mod_deflate/1.0.19 mod_accel/1.0.30 mod_ssl/2.8.14 OpenSSL/0.9.6b
Content-Length: 711
Content-Type: text/xml; charset=utf-8
SOAPServer: SOAP::Lite/Perl/0.55
Connection: close
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode xsi:type="xsd:string"
>SOAP-ENV:Server</faultcode>
<faultstring xsi:type="xsd:string"
>Can't use string ("SOAP::MessagingEngine") as a HASH ref while "strict refs" in use at /home/mod_perl/hm/MailApp/SOAP.pm line 144.
</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope> |
I think this will not be difficult to correct on your side.
The future
I read a few article on SOAP::Lite and found that modifying a lite the code could help because of SOAP RFC and SOAP "best practices"
For example the SOAPAction default behaviour for
SOAPAction: http://www.alfredbr.com/#HelloWorld
and could be
SOAPAction: http://www.alfredbr.com/HelloWorld
Also the URI that is http://www.fastmail.com/soap and the SOAP that wait for http://www.fastmail.com/SOAP (upper case), ok, why not but it give more job to the developper.
Today my code is (with error in the answer)
| Code: | using System;
using System.Web.Services.Protocols;
using System.Web.Services;
using System.Xml.Serialization;
namespace FastMailSOAP
{
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Namespace = "MessagingEngine")]
public class FastMail : System.Web.Services.Protocols.SoapHttpClientProtocol
{
public FastMail()
{
this.Url = "http://localhost:8080/soap/";
//this.Url = "http://www.fastmail.fm/soap/";
}
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.fastmail.fm/SOAP/MessagingEngine#CreateSession",
RequestNamespace = "http://www.fastmail.fm/SOAP/MessagingEngine",
ResponseNamespace = "http://www.fastmail.fm/SOAP/MessagingEngine",
Use = System.Web.Services.Description.SoapBindingUse.Encoded,
ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public string CreateSession(string UserName)
{
object[] results = this.Invoke("CreateSession", new object[] { UserName });
return ((string)(results[0]));
}
}
} |
Some modifications could give .NET developers a better code.
My questions
- Can we still change the way the SOAP server works to correct some default behaviours and ease developper's life ?
- Jeremy, could you look at the produced error ?
Sincerely,
Remi |
|
| Back to top |
|
 |
Jeremy Howard The "e" in e-mail
Joined: 09 Apr 2002 Posts: 325 Location: Melbourne
|
Posted: Wed Aug 27, 2003 2:31 am Post subject: Re: First .NET Tests |
|
|
| rthomas wrote: | | ...I think this will not be difficult to correct on your side. | Are you still getting this error? Have you checked the SOAP packet matches that produced by the Perl test (uncomment the 'trace' line in SOAP::MessagingEngine to test)?
| rthomas wrote: | | I read a few article on SOAP::Lite and found that modifying a lite the code could help because of SOAP RFC and SOAP "best practices" | Can you link to the relevent article(s) for me to read?
I'll look into why that is happening.
I would like to make things easier for .Net developers where possible, as long as it doesn't cause problems for other languages. |
|
| Back to top |
|
 |
stuarteggerton
Joined: 15 May 2002 Posts: 10
|
Posted: Wed Aug 27, 2003 5:28 am Post subject: |
|
|
Jeremy,
I will keep going with the Delphi stuff and post some code when I get something workable. At the moment I am just sending back and forth raw headers not getting the data from them...
I'll try and have a look over the next couple of days and hopefully get a basic example going soon which I will post... |
|
| Back to top |
|
 |
rthomas
Joined: 25 Aug 2003 Posts: 11 Location: France, Lille
|
|
| Back to top |
|
 |
rthomas
Joined: 25 Aug 2003 Posts: 11 Location: France, Lille
|
Posted: Wed Aug 27, 2003 7:09 am Post subject: Another approch |
|
|
I also tried with some other encoding
| Code: | POST /soap/ HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 1.1.4322.573)
Content-Type: text/xml; charset=utf-8
SOAPAction: "MessagingEngine#CreateSession"
Content-Length: 517
Expect: 100-continue
Connection: Keep-Alive
Host: localhost:8080
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="MessagingEngine" xmlns:types="MessagingEngine" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><types:CreateSession><UserName xsi:type="xsd:string">xtware</UserName></types:CreateSession></soap:Body></soap:Envelope> |
and get the error
| Code: | HTTP/1.1 100 Continue
HTTP/1.1 500 Internal Server Error
Date: Wed, 27 Aug 2003 07:03:39 GMT
Server: Apache/1.3.27 (Unix) mod_deflate/1.0.19 mod_accel/1.0.30 mod_ssl/2.8.14 OpenSSL/0.9.6b
Content-Length: 701
Content-Type: text/xml; charset=utf-8
SOAPServer: SOAP::Lite/Perl/0.55
Connection: close
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode xsi:type="xsd:string"
>SOAP-ENV:Client</faultcode>
<faultstring xsi:type="xsd:string"
>Failed to access class (MessagingEngine): Can't locate MessagingEngine.pm in @INC (@INC contains:) at (eval 304) line 3.
</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope> |
For me it make my code very simple.
Perhaps for you it's very easy to handle this ?
Remi |
|
| Back to top |
|
 |
Jeremy Howard The "e" in e-mail
Joined: 09 Apr 2002 Posts: 325 Location: Melbourne
|
Posted: Wed Aug 27, 2003 5:04 pm Post subject: |
|
|
Remi, your namespace is wrong. You have 'MessagingEngine'. It should be 'SOAP/MessagingEngine'. The Perl client generates: | Code: | | xmlns:namesp1="http://www.fastmail.fm/SOAP/MessagingEngine" | This is why it searches unsuccessfully for MessagingEngine.pm, rather than successfully for SOAP/MessagingEngine.pm. |
|
| Back to top |
|
 |
Jeremy Howard The "e" in e-mail
Joined: 09 Apr 2002 Posts: 325 Location: Melbourne
|
Posted: Wed Aug 27, 2003 5:13 pm Post subject: Re: First .NET Tests |
|
|
I'm happy to put in the time to get this to work.
In the two attempts you've shown, was that the *entire* transaction? It failed after the very first request?
I couldn't see any ideas in the links you provided regarding changes I should make on the server side. Did you find some specific changes to make? Most of the links covered client-side SOAP with server-side .Net. |
|
| Back to top |
|
 |
Jeremy Howard The "e" in e-mail
Joined: 09 Apr 2002 Posts: 325 Location: Melbourne
|
Posted: Wed Aug 27, 2003 6:13 pm Post subject: |
|
|
OK, I see the problem. The Perl client uses a single hash to pass all info: | Code: | my $Self = { UserName => $UserName };
CreateSession($Self); | (I've simplied the code slightly above to make it easier to understand for non-Perl programmers). So $Self, which is passed to CreateSession, is serialised as a soap-struct by SOAP::Lite. You need to pass a struct with one element (UserName, a string), but currently you're just passing a string. |
|
| Back to top |
|
 |
rthomas
Joined: 25 Aug 2003 Posts: 11 Location: France, Lille
|
Posted: Thu Aug 28, 2003 8:44 am Post subject: Need to do more tests |
|
|
Hi,
Jeremy I did a lot of tests (during about 8 hours) trying to build a correctly formated SOAP envelope from Visual Studio .NET and can't do it. It's not possible with the SOAP engine available in the .NET Framework. I need to work at a lower level and manipulate the XML to achieve it.
The Perl client you provide encapsulate the parameter sent to the method in a SOAP__MessagingEngine tag. This is the first time I see this (the SOAP standard is a little complex) and I don't know how to do this in .NET.
The Perl client SOAP message
| Code: | <?xml version="1.0" encoding="UTF-8" ?>
<SOAP-ENV:Envelope xmlns:namesp2="http://namespaces.soaplite.com/perl" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Body>
<namesp1:CreateSession xmlns:namesp1="http://www.fastmail.fm/SOAP/MessagingEngine">
<SOAP__MessagingEngine xsi:type="namesp2:SOAP__MessagingEngine">
<UserName xsi:type="xsd:string">xtware</UserName>
</SOAP__MessagingEngine>
</namesp1:CreateSession>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope> |
I created a Windows Media video to show you how it's easy to consume web services from Visual Studio.NET.
http://www.pixel-technology.com/video/consumews.wmv
I think with SOAP::Lite we can do the same. To find how I installed Perl on my machine and begin to build a SOAP::Lite server (I'm not a PERL expert but did use it a few years ago)
I will come back in a few day with the solution.
Sincerely,
Remi |
|
| Back to top |
|
 |
|