I recently realized that it's a stretch to call the web services my company publishes as xml web services. We've always documented them as xml based, but that's a stretch. We use .Net which makes creating a web service almost brainless. We have implemented our web service as such:
[WebMethod]
public string Echo(string message) {
return "<EchoResult>" + message + "</EchoResult>";
}
This is a really simple example, but the web service accepts a string and returns a string. The string in our web services is an xml message which gets dispatched to the appropriate handler later on. So we're handling a variety of different messages and responses through a single interface using an xml string as the parameter.
What you don't realize is that this is so far from what you really want to be doing is isn't even funny. Sending a request to this method must be sent as (simply, using SOAP there would also be a SOAP wrapper):
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://foobar">string</string>
The string parameter in this case is wrapped in the string xml element. Because of this requirement the string being passed to the web service must be xml encoded to ensure the entire request is valid xml. So in our case where the string is potentially a very large xml document, the entire message must be xml encoded. The response from the web service is similar:
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://foobar"><EchoResult>test</EchoResult></string>
In this case the string "test" was passed to the web service. As you can see, the response is xml encoded. This again is to ensure that the xml is valid.
Because .Net makes creating these web services brainless the xml encoding is handled by .Net auto-magically. So if you are taking to the web service with a .Net client and created a web reference, the xml encoding and decoding happens behind the scenes and you won't even know it and it looks like you're passing xml messages back and forth. Now technically you are passing xml messages back and forth, but it's not pretty (IMHO). If you try to use a Java client(pick your language) the request won't work till you xml encode the xml message and you won't get your xml response unless you xml decode the response ... doesn't seem like a friendly xml interface.
A way to get around this implementation is to use XmlNode:
[WebMethod]
public XmlNode Echo(XmlNode message) {
XmlDocument dom = new XmlDocument();
dom.LoadXml("<EchoResult>" + message.InnerXml + "</EchoResult>");
return dom;
}
By specifying the parameter and return type as XmlNode, the web service accepts and returns xml. If you peak at the WSDL you'll see. So with this implementation the request does not need to be xml encoded since the web service accepts xml. The response is also not xml encoded since it returns xml. Although .Net clients will see that the parameter and return types are XmlNode, to other clients it will just look like a string. The response using the XmlNode implementation looks like:
<?xml version="1.0" encoding="utf-8"?>
<EchoResult>test</EchoResult>
This is what you'd(I'd) expect to see when calling a web service that you expect to pass and receive xml messages.
I guess one lesson to learn from this story is that if it looks too good to be true -- it probably is.
Another lesson to learn is to understand the technology you're using. I stumbled across this when I was running WireShark troubleshooting something else.
Hope this proves useful for someone else.
Wednesday, February 20, 2008
Saturday, February 16, 2008
Expect More
I think I'm in the majority when I say that I'm sick and tired of the federal government wasting our (the people) time and money. On Friday I was listening to Michael Medved talk about the House taking up baseball and steroids ... again -- man, what a waste of our time and money! I don't even understand what they must be thinking to think that it's a good idea to bring the case of baseball and steroids before the House. How is that an issue the federal government needs to get involved in? There are so many federal programs and other things like this that are such a huge waste of time.
On Michael's show he had a government employee on the who was talking about working on identifying and getting rid of or cutting back the worthless programs the federal government is involved in. He directed people to ExpectMore.gov to see the programs they have identified. I think I heard him say that they have identified over 1100 programs totaling 2.3 TRILLION dollars that should be reduced or done away with. It's so hard to ever come to grips with that large of a number. I hope this organization is successful in getting rid of some of these worthless programs and wasteful spending.
Did you know Amtrak is a government subsidized program? On ExpectMore.gov it says,
Anyway, we need to expect more from the government. Not only expect more, but demand more. We need to make our voices heard.
On Michael's show he had a government employee on the who was talking about working on identifying and getting rid of or cutting back the worthless programs the federal government is involved in. He directed people to ExpectMore.gov to see the programs they have identified. I think I heard him say that they have identified over 1100 programs totaling 2.3 TRILLION dollars that should be reduced or done away with. It's so hard to ever come to grips with that large of a number. I hope this organization is successful in getting rid of some of these worthless programs and wasteful spending.
Did you know Amtrak is a government subsidized program? On ExpectMore.gov it says,
Amtrak was formed in 1970 to be the Nation's sole provider of intercity passenger rail service. It operates in 46 states and owns and manages the Northeast Corridor rail infrastructure. Though it requires Federal subsidies, Amtrak is a for-profit corporation and makes management decisions independently of the government.Does that sound like a government monopoly to anyone else? Why did the government need to get involved in that anyway? Why can't we just let the free market/capitalism take care of "intercity passenger rail service"?
Anyway, we need to expect more from the government. Not only expect more, but demand more. We need to make our voices heard.
Friday, May 26, 2006
Root Causes
Ive been an active observer of our political system and current events for some years now. Im not an expert, I dont have all the answers; just an opinion on everything. But I've always had a nagging question, and its applies to every issue that comes up. Its a very simplistic question, and probably seems foolish to some. Why doesnt everyone think as I do? Seem stupid? Let me give you an example to make my point.
(Shamelessly snagged from Bill O'Reilly.com)
The State of California is taking action. Earlier this month, the state senate voted 22-15 to prohibit textbooks or instructional materials that "contain any matter that reflects adversely" on persons because of their ethnicity, gender, disability, nationality, sexual orientation, and religion. In addition, the proposed law would mandate textbooks include the study of "people who are lesbian, gay, bisexual, or transgender, (and who have contributed) to the economic, political, and social development of California and the United States of America ..."
Take a breath, and consider the implications. If I were a Nazi, and I read any rational history of World War 2, I would feel like it was 'reflecting adversely' on my nationality. If I were a gay man, and I read any kind of rational history of the AIDS disease, I would likely feel that it was 'reflecting adversely' on my sexual orientation. For those of you who dont know, AIDS originally flourished among homosexuals. Sorry to offend you. So, under this law, we can still have history. Just not rational history.
But back to my point, and I ask it in genuine bewilderment. How can ANYONE not think that this legislation is anything but absurd and harmful to everyone it affects. Thats what I dont understand. And it applies to everything; Immigration - why wasnt this insane situation stopped 3 presidencies ago? Gas/Energy situation - is anyone actually surprised we are paying $3.00 a gallon at the pump? Come on, people have been predicting this for decades. No rational person can be surprised. Theres that word again.
In answer to the question, let me say that the greatest strength of our governmental system lies in the fact that every citizen has a voice. Every citizen has a vote. But herein too, is the greatest deficiency of our system, and our greatest peril. For when every man has a vote, then all that is required by one who would work great evil is to convince the masses that that which is evil is not really evil. Our Founding Fathers believed that Democracy would only work if founded upon two principles: Religion, and Education. Once the people become corrupt or misinformed to a certain degree, the whole thing falls apart.
So whenever I get discouraged about the state of things, I am reminded that the answer to our dilemma isnt sweeping legislation, or some new policy in our government. You see, democracy can only work in a society of righteous individuals; and thats the crux of it all. The proper programs, institutions, laws; these are important. But the system will work if and only if the people uphold moral principles in thier personal lives. No combination of other factors, taken together or singly can save or doom our society.
(Shamelessly snagged from Bill O'Reilly.com)
The State of California is taking action. Earlier this month, the state senate voted 22-15 to prohibit textbooks or instructional materials that "contain any matter that reflects adversely" on persons because of their ethnicity, gender, disability, nationality, sexual orientation, and religion. In addition, the proposed law would mandate textbooks include the study of "people who are lesbian, gay, bisexual, or transgender, (and who have contributed) to the economic, political, and social development of California and the United States of America ..."
Take a breath, and consider the implications. If I were a Nazi, and I read any rational history of World War 2, I would feel like it was 'reflecting adversely' on my nationality. If I were a gay man, and I read any kind of rational history of the AIDS disease, I would likely feel that it was 'reflecting adversely' on my sexual orientation. For those of you who dont know, AIDS originally flourished among homosexuals. Sorry to offend you. So, under this law, we can still have history. Just not rational history.
But back to my point, and I ask it in genuine bewilderment. How can ANYONE not think that this legislation is anything but absurd and harmful to everyone it affects. Thats what I dont understand. And it applies to everything; Immigration - why wasnt this insane situation stopped 3 presidencies ago? Gas/Energy situation - is anyone actually surprised we are paying $3.00 a gallon at the pump? Come on, people have been predicting this for decades. No rational person can be surprised. Theres that word again.
In answer to the question, let me say that the greatest strength of our governmental system lies in the fact that every citizen has a voice. Every citizen has a vote. But herein too, is the greatest deficiency of our system, and our greatest peril. For when every man has a vote, then all that is required by one who would work great evil is to convince the masses that that which is evil is not really evil. Our Founding Fathers believed that Democracy would only work if founded upon two principles: Religion, and Education. Once the people become corrupt or misinformed to a certain degree, the whole thing falls apart.
So whenever I get discouraged about the state of things, I am reminded that the answer to our dilemma isnt sweeping legislation, or some new policy in our government. You see, democracy can only work in a society of righteous individuals; and thats the crux of it all. The proper programs, institutions, laws; these are important. But the system will work if and only if the people uphold moral principles in thier personal lives. No combination of other factors, taken together or singly can save or doom our society.
Wednesday, May 24, 2006
Usability
I was just reading a post from Creating Passionate Users comparing good usability to "water flowing downhill". In a nutshell the post is talking about making the right things easy and the wrong things hard -- making the right things natural, like "water flowing downhill". They have quite a few examples, here's one:
Anyway, I've started (I opened the cover) reading Don't Make Me Think by Steve Krug. It's supposed to be really good. Hopefully I can learn some good stuff on UI design from it. Every developer should be good at interface design, be it web, forms, API, framework, ect.
Defining what your code should do should be challenging. Figuring out which API methods will give you that capability should be simple.And the quote I really enjoyed is:
Playing the game should be challenging. The interface should be brainless.I'm not the best user interface designer, but I also don't think I'm the worst. I haven't always been too fond of creating interfaces, I like working "behind the scenes". Creating a good framework or API and seeing it used successfully is great. I've been doing more framework/API design and implementation lately and have really been enjoying it. I have also been doing a lot more UI work lately and always feel like it isn't quite there yet.
Anyway, I've started (I opened the cover) reading Don't Make Me Think by Steve Krug. It's supposed to be really good. Hopefully I can learn some good stuff on UI design from it. Every developer should be good at interface design, be it web, forms, API, framework, ect.
Tuesday, May 23, 2006
Asp.Net Nested Master Page Error
I was working on a website today using nested master pages and suddenly started getting the following error:
After searching around, I finally found this article on MSDN that talks about the error when using nested master pages. Basically if you are using nested master pages, the master pages must also be open at the same time. Weird, but it fixed the problem.
Just something I thought I would pass along.
'asp' is an unrecognized tag prefix or device filterIt was very odd. One minute the page was fine, the next it was broke. I tried to restart Visual Studio, but still the same error.
After searching around, I finally found this article on MSDN that talks about the error when using nested master pages. Basically if you are using nested master pages, the master pages must also be open at the same time. Weird, but it fixed the problem.
Just something I thought I would pass along.
Subscribe to:
Comments (Atom)
