I've written a small C# app to use the WSDL that
Randy has been writing/coordinating. A few small changes
to the WSDL were required to get this to a clean compile (try
compiling the app with the original WSDL to see what was needed,
one). On top of that, a bit more changes were required to
get it to produce a recognizable request. The latter changes
are the subject of this blog entry.
If you look at the
it starts out simply enough. Get a few parameters from the
command line. Create a blog entry. Fill in some
fields. Set issued to DateTime.Now... and let all the pesky
serialization and marshalling details be taken care of for
Nested structures and attributes are no problem. Those map
to strongly typed datastructures. If you use an IDE, you can
Intellisense. The content element is pretty
straightforward... with the XMLDocument class doing all the heavy
lifting. You even get an enumeration for the mode attribute,
so this value can be checked at compile time.
Then you get to the
Username Token header. At this point, there are a number
If you are have
WSE installed, the choice is easy. You can take advantage
of the Username token support that is already built in. Get
the SoapContext, add the Token, and away you go. Here's some
Oh, and if you aren't using Microsoft.Net, Axis has a
handler. Use it. And if you aren't using Axis, then
find out how your platform vendor supports this, and use their
As you might have guessed by now, I didn't go that way.
Your next choice is to build the XMLNodes using XMLDocument,
much like I did for content, and provide that for the header.
This isn't all that difficult, but you do lose the benefits
of having the generated classes, IDE, and the like. This may
seem like a stark choice, but it is important to know that it is
And as you might have guessed again, I didn't go that way
either. Warning: there be dragons ahead.
Building the security header using the generated classes starts
out pretty simple. There are System classes that provide
things SHA1 cryptography support, and base64 encoding. All
that is left is to fill in the fields.
The first sign of trouble comes in with the computation of the
hash. This requires that you know what the value of the
created element is. By that, I don't mean the date, but
actual characters that this date will be serialized as.
Remember all those pesky serialization and marshalling details that
are taken care of for you? Well, now they matter. You
need to know what time zone and what fractional seconds the runtime
will provide for you, before this all is serialized and sent
over the wire.
One way to regain control is to simply declare this one element
as a string. It isn't that hard:
ToString("u") pretty much does the right thing anyway. I
say pretty much, as it uses a space instead of a "T" as a
separator, but one call to
Replace and this is cleaned right up.
First problem down, now onto the second one. This is the
Password Type is supposed to be wsse:PasswordDigest. In
XML jargon, that's called a
name, or a qname for short. Ask Mark Nottingham, he
are evil. He's got a point.
Here, the problem is similar. The prefix "wsse" needs to
be declared to map to a
namespace. The name of the prefix doesn't matter, what it
maps to does. That would be fine, but this is another one of
those pesky administrative details that the tooling takes care of
for you. Except that it doesn't know about this usage as it
is "tunneled" inside an attribute.
The first workaround I tried was declaring an attribute named
"xmlns:wsse" in the WSDL, but .Net is too smart. This
attribute is simply eaten.
The second workaround I had better luck with. I declared
that this element supported anyAttribute and then procedured to
construct a specific attribute with the correct prefix in the
code. The name of this attribute doesn't much matter as it
merely is a ruse to get the namespace prefix declared.
This seems to work. Now I produce a recognizable
Summary: if you have the opportunity to use WSE or Axis,
then removing the security header from the WSDL is the way to
go. Otherwise, The above looks to be one means to get the job
done using the version of .Net that is available on Windows
Thanks a lot Dude. You are a C# god! I won't tell anybody at Apache ;) I'll see about trying to get all this into my next WSDL.
Here's an RSS 2.0 to Atom syntax XSLT that iM working on. The tough part was the date. If someone ever invents another date format, then send me their email address, I've got some friends who'll take care of them. Try it out and give me some...
In some server applications, the client is permitted to assign URIs to new data. In those contexts, PUT can also be used to create new content. In other settings, the server reserves the right to assign URIs, in which case POST is needed. Posting a comment is a typical example.
Quote: Via Sam Ruby (who built a small C# app based on the ATOM WSDL), we find Randy Charles Morin, who has created WSDL for ATOM. Atom, which, as it turns out, isn't an acronym for anything, is the heir-apparent to RSS....
A discussion on the Atom Wiki should make it possible for clients that lack PUT and DELETE to fully implement the Atom API. If folded in to the next revision of the API, this enhancement will make J2ME Atom API clients a...
I've been trying this code with Blogger.com, no joy at all.
Blogger.com returns a SOAP fault with the following exception:
java.lang.ArrayIndexOutOfBoundsException: 7 at com.google.common.Base64.decode4to3(Base64.java:417)
I know my username/blogid/password are correct - everything from tcpTrace looks great. Any suggestions?
MyCGIServer free offering has been discountinued. I have my own reasons to disregard their bargain prices, so this weblog and all related resources will be dismissed in the next few days. Update: or maybe not, since Javalobby has come to the rescue....
Hi, Pradeep. To create any kind of Node (Element, Attribute, etc.) in the DOM, you need to have some kind of context. This context lies within the DOM itself, so to create an XML element, you write doc.CreateElement(..). The return from this method is your new element.
I'm working with the vb client example; but can't seem to get the userid password url combo to work. For example at www.blogger.com user I assume to be my userid, password my password, but what is the url? [link] doesn't work
Also, am I free to use the atom api in my code (which I want to sell)?
Sam's got big ones ... working for IBM and actually using C#. But it's also clear that he knows the APIs inside out and outside in. He defintely makes my top 10 list for the year of folks who are helping to dramatically advance the state of the art. Sam Ruby: Atom API via WSDL......
DaveJohnson created this page on Sat Jul 24 05:35:53 EDT 2004:AtomAPI The Atom API is a web services API for weblogging applications. See also Atom Atom4J AtomFormat WeblogAPIs MetaWeblogAPI BloggerAPI Resources The Atom API Specification...
I am trying to write a client app that uses the Atom API to make posts to a blog on Blogger. Using the sample app by Sam Ruby and after customizing the .wsdl to point to "http://www.blogger.com/atom/", I get the following error when I try to post:
"The request failed with HTTP status 405: Method Not Allowed."
Danny Ayers: Tonight I planned to get to the bottom of problems I encountered last night (while tired), working on a minimal SOAP-based (WSDL-generated, C#) Atom client. My starting point was the marvellous material put forward by Sam and...
This ATOM API doesn't work for me either when trying to post to blogger.com. Tried the C#/SOAP and build-by-hand ways. I guess no one tests this stuff. Build an API that doesn't work. Oh yea! <vent>"Build it and they will come... then pull their hair out trying to decipher java stack traces and leave."</vent>
My stubbornness overcame my apathy and laziness and I googled enough to find enough information to get the C#/WSDL example code to supposedly successfully post (return code 201) to a blogger blog on blogpost.com.
The downside is that you won't be able to edit your blog via blogger's web interface not will you be able to republish your blog.
Unless you want to freeze your blog in time, this is not a feature.
So I'll wait until the blogger folks get their act together before I post the necessary diffs to the C#/WSDL sample code.
Excuse me, could any one here mind guiding me along? i am currenly doing a pocket blogger application using C# and i found this coding very useful for me. i have it’s reference downloaded as well, however, there is this error kept coming out after i have deploy it in the emulator. the error msg shows “System.TypeLoadException”. i don’t understand how to debug that’s why i’m stuck here.
isit something that i need to add before this coding? like the namespace must be the same as reference? or i need to have something "using classname: referenceName"?
Tortuga.Blogger blogger = new Tortuga.Blogger();