Tuesday, November 17, 2009

So you think you do PunchOut?

I’ve had – in the last week five emails from people asking for help with PunchOut eProcurement systems.  One or two isn’t uncommon but five or six becomes a trend.    So in an effort to reclaim my evening hours for watching House, Supernatural and helping my son with his homework (we’re doing Harper Lee’s “To Kill A Mockingbird” this week)… I thought I’d round up some of the more frequently asked questions I’ve seen.

Q: What is OCI? 
A: OCI is the Open Catalog Interface.  It’s largely used by SAP – and yes, believe it or not can be used with cXML.

Q: What is EBD Format?
A: EBD is the EPO Bibliographic Data Format… which is a mouthful and yes – there are companies, usually those dealing with legal documents such as patents and such that sell them online.   EBD in the case of SAP and Punchout however does not use this format… what you’re referring to is SAP Enterprise Buyer Data which isn’t a format it’s an application.  You use this if you want to create a process for direct and indirect shopping and the shopping cart ends with the entry of the invoice.

Q: What is the difference between PunchOut, TapOut and Roundtrip?

A: Contrary to an article and paper sent out by a service consultancy a while back… PunchOut, TapOut and RoundTrip – are all the same thing using different methods (IMHO – but then I’m Old School and picky about my definitions and not trying to sell something).  They’re eCommerce Shopping solutions that involve a shopping catalog “punchedout” and sent to a customer from a vendor.  Ariba’s name – which is the oldest is PunchOut, Commerce One and a few others call it  “RoundTrip” and Commerce One likes to use “TapOut”.  Bottom line … it’s all B2B – the only difference is the methods used to get there. 

 

I’ll toss out more later on in the week – but figured this was a start for the week since I hadn’t posted in a while. 

Friday, September 4, 2009

Testing… Testing… Testing… is this thing on??

Been far too long since I posted anything, and I feel like crud for that since I have been keeping up on emails and know how many people have been asking if I died or something … nope.  No deaths, alien abduction, undercover spy operations or world saving.  Just a ton of work and barely enough time left over to sleep let alone post anything on the blog.  Since at work they seem to be a bit behind the times (and our department below the budget) I’ve had to come up with inexpensive ways to design, develop and test stuff.  So in keeping with my on going mantra here on the blog of showing you how to do more with little or no cash I thought I’d share a few of the free testing and dev tools I’ve been playing with of late.

image The first of which is a little beauty called the WaitN Test Recorder.  It’s an awesome tool for recording and playing back tests.   And it will set you back a cool bupkiss.  A big Nada.  Zero.  Zilch.  Zippo… totally free – which your boss will love. If you do any work on the web … this is your baby for testing.  Combine it with the rest of the WaitN line of toys and you’re good to go for most web based tests.

 

Next “Thing You Gotta Have that’s Free…” in my toybox of free tools are … the Microsoft Visual Studio Express tools.  Now… I know, I know, I know these are “kiddie” versions are what you’re  image going to tell me.  Now – let me tell you… I’ve coded a ton of apps in these for work because, well, my department isn’t going to pay for a full blown MSDN Universal Subscription… heck, they probably wouldn’t pay for a copy of VS Pro… but these are FREE.  And that’s free as in FREE BEER free – you pay nothing for them.  All of the code that I’ve written in them is as good or better than the full blown Visual Studio.  No, you don’t have all the cool features – but you have enough of them that you’re using probably one of the slickest IDEs on the market even in it’s free version it’s still light years ahead of everything else out there.

So… if you need to whip up an app quick and easy – or even a somewhat complicated application, or if you’re just starting out and want to learn a language or two… this is the way to go.  Now… for those who are saying “Yeah but why can’t I get the FULL Visual Studio IDE for free?” – got a surprise for you… you can.  In fact you can get that and your choice of RUBY or IronPython along with it … for free.

So… for those who don’t do VB.NET, C#, etc., and you want to try the new stuff out there… you’re going to love this – RUBY with a Visual Studio IDE.  Yup… RUBY.  Say no more … and it’s also free.  SaphireSteel Software makes an awesome free version of it’s RUBY editor for Visual Studio, which, btw, just happens to include a copy of the Visual Studio IDE free if ya don’t happen to have one lying around, as well as RUBY, and MYSQL if you need a database.  So… how’s that?

What’s that you say?  You want something … to handle subversioning?  (What’s subversioning you say?  hmmm… Do I need to take you to an ER to have you checked for head trauma???)  A subversion tool is a tool used to track versions, revisions to code, and provide a source control system for software development. 

How many times have you written code… then had a brilliant Idea that was just so awesome that you didn’t back up your code… and accidentally wrote over your code?  C’mon… show of hands… fess up… everyone’s done it. 

Wouldn’t it be cool if there was a magic fairy that would come down and allow you to see previous versions of the code you’d written – allow you to compare it or even revert back to a previsous version?  As if by magic? 

Well there are several tools for this…  and once again… they’re FREE.  The first one I wanted to talk about is called TortiseSVN.  Now … straight off the box it says TortiseSVN is “A Subversion client, image implemented as a windows shell extension. TortoiseSVN is a really easy to use Revision control / version control / source control software for Windows. Since it's not an integration for a specific IDE you can use it with whatever development tools you like. TortoiseSVN is free to use. You don't need to get a loan or pay a full years salary to use it. “.

There are a ton of free development tools out there that can really help your projects and give you the quality and degree of professionalism you’re looking for – that are free and that can free up your cash for other things.  Which if you’re a small shop or a struggling but scrappy start up shop trying to create the next Google – you’re not forced with the choice of doing things half-way or the wrong way because it would cost you an arm and a leg.

  So what’s that mean to you?  It means you can imagenow track your changes to the code.  You can now auto-revert to a previous version.  It means that when you screw up… and we all do… you can fix the problem faster and more efficiently – like a professional.   You reduce your costs, increase your efficiency – and you provide yourself with a safety net.   Good times.  :D

But… but… but… what about better support for all those cool MS Visual Studio Express tools and the free Visual Studio IDE that came with your spanking new RUBY editor from SaphireSteel?  You go into VS Express editions and you don’t have subversion?  Well actually you do – but it’s not integrated nicely into things like you’d like.  Truth is – there are some featurFor that… you want AnkhSVN. image

image

  AnkhSVN integrates directly with the Visual Studio 2008 IDE.  You get the familiar looking blue / green / red check marks on the files you’re working on in the Solution Explorer.  You get the very nice docking panel which provides details on imagefiles.  And best of all – it’s all built in.  No need to kill yourself trying to jump back and forth and open up new windows to work in.

 

 

Now… those are just a few of the toys you need to make a yourself into a professional operation for free.  But … what other goodies do I have for free???   Well there is this cool tool you probably never considered… the Microsoft AdCenter Demographic Analysis tool…  really.  If you really need to understand why this is handy you should imageprobably not be reading this.  Demographics for a website are a key to selling it.  For example – this site is meant for a very wide demographic, and this handy little gizmo gives me some proof of that.  It shows that the site is very evenly distributed amongst the various demographic types it’s meant for namely the 25-35 age group.  You’ll find several very use tools over at the AdCenter for web sites so be sure to check it out.

I’ve got tons more… but this should get you started for this week and keep people from asking me if I died or was kidnapped by aliens. 

Friday, July 10, 2009

Doing a lot for very little…

Just when you thought it was safe… I drag you back into cXML validation! Hey – put down the torture devices…. it’s not what you think!  Remember a few posts back – we built a quicky validation tool?

imageWell had someone ask if I actually use that, and the truth is – no I don’t.  The actual tool that I use is the one shown here.  But all of this began as something very similar to the code you saw here.  There’s a lot more exception handling – and slew of features added into it since we / I use this for all kinds of cool eCommerce tests around work.  

As you can see the initial purpose of the tool remains the same, which is to validate cXML documents.  With this I can load the documents into the tool – and using any of the pre-populated addresses – it is capable of process an actual file, which is to imagesay round tripping where we begin with the PunchOut set up request and go all the way through the Purchase Order (OrderRequest) and even the POOM (PunchOutOrderMessage).

It was built completely on the free VB Express system from Microsoft so it cost literally nothing to build.  Were I to sell this – I’d probably charge around $500 to $1200 depending on the added features I’ve put in there and people would I have no doubt pay that for it.  (I know because I’ve been offered that much for it).  So there’s no reason that with a bit of ingenuity someone looking to really add to their portfolio or even just make a few dollars can’t do this. Which is kind of the point to the exercises that I put up here. 

With the economy currently in shambles for the tech industry there’s a lot of things you can do for very little cash that can reap some good rewards.   You don’t have to spend $$$ or have a lot of start up cash, software or hardware.  What you need is to sit down and say, “What tools need to be imagebuilt?”, “What do I need to do my job better?”. 

There is always a better mousetrap out there – and even if your budget is nil – all it takes is some very basic coding skills to make something that you, your department, your boss really needs.

Thats the root of it really using your skills to their best advantage.  If you happen to make a really great whatever so much the better.  And you’ll note I don’t use some exotic code – I use the very basic, very simple Visual Studio Express and a bit of code here and there to really  create a tool I need for my job.  This one was built because we didn’t have any test tools like this where I work.  Once again – you see a need – you build a tool.  The more you build the more indispensable you become.  Don’t wait for your job to out pace you  … out pace the job.  Create things.  Get messy.  Have fun.  It’s when we do this that we stand out form the crowd and get noticed.

Just some food for thought… take care until next week.

Wednesday, June 24, 2009

PM Work: Some Required Assembly…

Haven’t had much to say about Program Management in a while so decided to talk some stuff I ran into at a recent  ScrumMaster seminar.

Now I love scrum as much as anyone.  You got your Chickens and you got your Pigs, and who isn’t going to love a PM method that’s got roles based around an old vaudeville sketch about farm animals right?  Okay… so I love scrum as a method of project management for other reasons than that – but lets face it that is pretty bizarre. 

Now, it’s all really cool to have this great method to reduce time to product, reduce costs and increase quality.  And it’s all great to use agile methods.  But the fact is that Scrum and Agile aren’t for every project and they’re not for every team. 

They are not a one-size-fits all method of development but they’ve become very much a defacto standard for everything and used without really a lot of good reasons other than the teams involved have used them before they worked.  Which is a good reason to try, but that doesn’t mean that because it worked once it’s going to work again.

My daughter has a car.  It’s a great little Berretta and it’s very old.  Now, I used to have a really great Turbo Capri from about the same year as her Berretta and when it gave me fits, I replaced the starter and it worked well.  Unfortunately, my Daughters Berretta has a problem with it’s ECM and replacing the starter isn’t going to help it.  It needs a new ECM and it won’t matter whats worked for me in the past.

 raj_gather So before I go into a project and decide that Scrumming it up is a good idea I need to talk to a few people. 

I need to talk to the people who are going to work on it.  I need to talk to the people who are going to pay for it.  I need to talk to the people who are going to use it.  I also need to talk about if it’s even remotely possible.

Basically before I can even decide on if I want to be in the project - I need… Project Requirements. 

Which is something I’d like to toss out there as a PM and a process I’d like to talk about.  When people approach you with a project you need to really understand all the requirements of the project itself. 

Now, not everyone who’s a PM is in a position to pick and choose their projects.  But even if you didn’t get to pick your project(s) you should do this every time you have a project dropped on you.  If you’re going to drive a project then you need to know everything you can about it. 

When I start a project I personally go through this.  I sit down and I write up, for my own understanding in a very rough outline form, the project General Requirements. 

My general requirements list is everything that are currently defined requirements that are known.  This is the starting point and from there I can determine the questions I need for my other lists.

I’ll create a short Systems Analysis, and in this I’m going to include all the things I can find out about what are the specific systems requirements I can think of and find out.  If the General Requirements have a preference  for a particular kind of programming language or a technology – I’ll hit the internet and write up the known specifications needed for that technology so when I sit down and have meetings for the real Systems Requirements I not only can understand what I’m being told but can actually participate in the discussion.  Here I’ll include anything I don’t know –all the questions that I can’t find answers for -  which are just as important as what I can find out, what I can know. 

Next I’ll move on the Functional Analysis and then the Design Analysis.  I’ll break it down something like this: 

  • System Analytics are about the physical properties needed to make the project happen.
    • What technologies?
    • What physical products will be needed?
  • Functional Analytics are about what it will actually take to make the project happen.
    • Do we need a lot of people to create this? 
      • What kind of people?  Experts?  Developers?  Designers?  Manager?
        • How many Pigs?  How many Chickens? 
        • Will we need Silverbacks or just Codemonkeys?
  • Design Analytics are about we really are trying to create.
    • Is it about quality and style?
    • Is it about ease of use?
    • Is it about cost?
    • Is it about doing something no one else has?
    • Who’s the market?  Who’s going to use this?  Why?

 

And most importantly for the Project – I’m going to play the Bosses Advocate and I’m going to ask all these questions again from the business perspective.  I’m going to look at the following – the Corporate Mission and Goals, The Department/Divsion Mission and Goals, and then the Teams Mission and Goals and I’m going to map all of these subjects to them.  So I know as many of them as possible so that when I need to go for funds I already have the answers the boss is going to ask me.

Now – that’s what I call a PM Project Requirements Analysis.  Now I won’t say every PM should do this but I can tell you that if you do you will find that as you go through these same steps again for the real thing, you will find that it will make you a better PM.  Its basically gathering all the things you need for a project before hand or at least as many as you possibly can before you need them so that when you need them you’re not just ready you already have the answers.

Take the time to write this up on a simple two-three page document for every project you have.  Take and use this as a blue print to feed into your Communications Plan, you need to use it to build as many of your docs as possible.  Then as time goes by you need to go back to the doc and update it.  Whenever possible a personal document like this should be considered a living document that you update over and over. 

Like I said, I can’t say if you do this your life will be puppies and kitties and rainbows.  But.I can say that if you do this – it will make your life easier and your projects easier. 

Just my 2 cents. 

a good POSR to validate against…. final thoughts on cXML PunchOut validation…

… and another email came in asking if I had a copy of a “good” cXML example I could share.

Actually, the best cXML examples are off of www.cxml.org which has a lovely link you can download imagethe files you need from.  If you always download their latest and greatest help, examples and docs at this link: http://xml.cxml.org/current/cXML.zip

Which will get you a very cool zip file that has samples for almost any kind of cXML operation you’re looking to pull off. 

image

Inside the zip is the examples directory – which is just piled all full of cXML goodies.  And in a blog or two ago I mentioned that humorously enough if you tried to validate any of those examples against the cxml.org dtd file… it would fail. 

And someone mentioned I never said why they fail other than they’re meant for very generic situations.  Which is … not entirely true.

 

It really depends on your outlook.  And if you want to see any of these files actually “validate” then you need to do one thing… change the DTD version in the DOCTYPE tag.  That’s the second line in the document and it would look like…

<!DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.2.020/cXML.dtd">
 

So in order to make any of these work… set it back to an earlier version which we know is compliant.  If for example you take the current PunchOutSetUpRequest and attempt to validate it against the DTD there’s a lot of fields which need to be implemented, and yes – you actually do have to add the appropriate Elements and Attributes under the tag to make it conform to 1.2.020 standard.  This sample to be honest is actually a 1.2.008 compliant DTD file – and to verify this simply change the validation dtd url to that version. 


<!DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.2.0008/cXML.dtd">


And you’ll get these results…






cXML Validated
Against the 1.2.008 DTD
Valid 1.2.008
cXML Validation Failed
Against the  1.2.020 DTD
Invalid 1.2.020 DTD

  


So the DTD really is the lord and master and it really does matter when it comes to validation.  It determines the rules by which the document is considered ‘good’, it covers how to handle whitespaces and escaped characters and all manner of things.  And with each DTD you have a slightly different set of rules that are applied. 


A file which validates fine against an earlier version can fail when validated against a newer set of standards.  So if you fail validation with DTD errors – try validating it against an earlier version. 

… and it comes in blue…

Got an email from Kedra A.– a developer/admin in Austin who wanted to know … if the cXML validator I put up this weekend could be done… using WPF.  Why Kedra wanted this in WPF I have no clue – but apparently all of their apps are now being done in… you got it – WPF.  Kedra tried building the project by just grabbing the various functions and subs and copying them into a WPF app and she couldn’t get it to work

I told her I’d take a look at it and see why.

So here it is.  Mission accomplished.  All done.

image Okay – I won’t be cruel .. because there are some code differences between any WPF and a normal .NET application. 

Basically there are very very few things in this app that won’t work in WPF.  But there are a few which, for various reasons need to be modified.

Primarilly this is the Richtextbox control and the OpenFileDialog/Showdialog, and these I found out after a bit of digging on the web … can be tricky.

So Kedra – don’t feel bad.  This is intermediate level to upper level stuff and it involves a very very new (for most people) technology. 

Lets take a look at the OpenFileDialog code in the original application and the wpf version here.

image image

If you notice the OpenFileDialog in the new code needs to instantiate the OFDialog as a System.Windows.Forms OpenFileDialog instead of the default that comes with WPF.  Why’d I do that?

'Set up the OpenFileDialog to get the name of the file for loading.
Dim OFDialog As New System.Windows.Forms.OpenFileDialog
With OFDialog
.FileName = vbNull 'Clear out previous filename
.FileName = "*.xml"



Simple … the OFDialog that comes with System.Windows.Forms.OpenFileDialog  is an easier to use – and has some richer features than the one that’s baked into WPF which is Microsoft.Win32.OpenFileDialog and has all the functionality of a sockpuppet.  Okay it’s not that bad… at least not until you try to use the ShowDialog to go with it. 



So that’s why… you can see I did this:



If OFDialog.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
If
.FileNames.GetUpperBound(iCount) < 1 Then
'File selected so put it in the ComboBox



In setting the OFDialog box to the Windows.Forms.OpenFileDialog in the top snippet – I can now use imagethe System.Windows.Forms.DialogResult and it’s various fun toys.  I also wind up with a much nicer OpenFileDialogbox.



I do need to use Import System.Windows.Forms; and yes… this does mean I’m refactoring but it’s a small price on code like this which is a quicky.



But … what other differences are there that you need to be aware of? 



Microsoft.Win32 RichTextboxes differ greatly from their Windows.Forms brothers.  As a rule most of the WPF controls are very similar – and at the same time very different from their cousins.  System.Windows.Controls.Richtextbox and System.Windows.Forms.RichTextBox are close – but no cigar.  If I want to change the text in a RichTextbox in WPF it’s a much different process than it’s Forms cousin. Check out the links above – and compare the code in the link below the the code in the previous post (it’s the same code – just updated for the WPF, and I removed a couple of annoyances I discussed last time).  



 WPF Validator Download Link












Side Note



- Kedra also wanted to thank me for doing my samples in VB.NET since its apparently hard to find code samples in VB.NET.  I agree with her for some reason there’s a hundred samples out there and the conversion I also agree is pretty simple… but the fact is there are still a lot of new programmers out there who need some time with the code before their confidence is strong enough to jump into those waters.  (They will get there – we all do – they just need to see shore for a bit longer while they work on their swimming.)  I will continue to do as many samples as i can in VB, but will also try to put them out in C# as well


Sunday, June 21, 2009

validating PunchOut cXML - pt 2.

Okay… so we covered a bit about POSRs in the last update.  And we kinda covered how it fit into an eCommerce Scenario… but let’s go into that more.

image

PunchOutSetupRequests are issued, and as we said last time the POSR (PunchOutSetupRequest) is sent from the Buyer to the Seller.  And they authenticate by sending an Identity and SharedSecret and a URL for the Seller to send a response back to.

So once the Buyer sends this authenticated message to the server, the Supplier (Seller) reads this message, authenticates the Buyrer and then sends back a URL which is the catalog of items which are for sale. 

This message that is sent back is called a PunchOutSetupResponse.  The Response message is usually nothing more than a “200” or “OK” message and the URL for the catalog.  If the message is anything other than a “200” – that means an error occurred.  “400” series errors generally mean a problem with redirections or locating urls, “500” series errors are server errors – which include the ever popular (and usually the most common) error message “500 Authentication Error”. 

A series 500 error can also mean that for whatever reason the cXML you sent didn’t process.  So it’s important that you have a valid cXML document to send and that’s where validation comes into things.

On the POSR, validation isn’t so difficult.  It’s basically just a From, a To, a Sender with Credentials, a BrowserFormPost URL – indicating where you want the Seller to respond to … and if you want to get fancy some Extrinsic values.  (We’ll talk about Extrinsics some other time since they’re a ton you can do with them – and they’re almost a discussion all their own.)

Where Validation is really important – is on the OrderRequest, also called a PunchOutOrderRequest (POOR) document.  You see in the flow of things you authenticate to the Seller and then then Seller sends you are response message, which has a URL to the catalog you’re going to be shopping at.

You do your shopping – all of this is recorded – and you send this information (your order – or PO) back to the Seller in the form of a PunchOutOrderRequest (POOR).  This has all the information needed to process the order. 

They look like this – which is an image of an actual order request : (Warning - a lot of Scrolling Involved here if you want to see … So Be Warned)

image

<?xml version="1.0" encoding="UTF-8"?>
<!
DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.2.019/cXML.dtd">
<
cXML payloadID="3223232@ariba.acme.com"
timestamp="1999-03-12T18:39:09-08:00" xml:lang="en-US">
 
Below is the Header – and this isn’t really going to be much different from the POSR we created, it goes FROM the customer shown below as “Admin@acme.com”.  You’ll notice (and someone did email me about this) that the “domain” listed below is “AribaNetworkUserId” and yes, you can change this. It says “AribaNetworkUserId” because this is one of the actual examples from www.cxml.org.   

Anyway – you’ll also note that there’s more than one Credential Identities
in the From field. Yup – you can do that too. When I have more time I’ll go into why this is a cool trick to use if your a Seller, but it’s one of those weird things that we don’t have time for today.So – moving on to the TO field, and the Sender fields – these are the same as the POSR.

   
<Header>
<
From>
<
Credential domain="AribaNetworkUserId">
<
Identity>admin@acme.com</Identity>
</
Credential>
<
Credential domain="AribaNetworkUserId" type="marketplace">
<
Identity>bigadmin@marketplace.org</Identity>
</
Credential>
</
From>
<
To>
<
Credential domain="DUNS">
<
Identity>942888711</Identity>
</
Credential>
</
To>
<
Sender>
<
Credential domain="AribaNetworkUserId">
<
Identity>admin@acme.com</Identity>
<
SharedSecret>abracadabra</SharedSecret>
</
Credential>
<
UserAgent>Ariba.com Network V1.0</UserAgent>
</
Sender>
</
Header>

We then move to the Request tag, which says “Hey this is a Request – it’s going to have tons of info in it. From there we get down to the OrderRequestHeader. Notice the “orderID”?

Thats generally the actual P.O. ID from many of your Buyer software ERP systems (most of them
actually) and right next to it – is the orderDate, also known in some software as the “createdDate”.

Next is the “type” – and it can be “new” or “edit” or even “delete”. And really that’s just the begining you see you have the ShipTo and the BillTo and the Contacts and we haven’t even begun to talk about ItemDetails – which are the actual items. A lot of these have rules to them, and there are some fields which are “optional but required”. Which means that, for example the Zip Code field is not required for a lot of software that processes the cXML… unless of course it’s got a isoCountryCode for the USA. Then it becomes required. Go ahead and take a look at this example and you can get some idea of how OrderRequests look.

This, btw, is a pretty short
OrderRequest. A real one may be many many many lines of text.

<
Request deploymentMode="test">
<
OrderRequest>
<
OrderRequestHeader orderID="DO1234" orderDate="1999-03-12" type="new">
<
Total>
<
Money currency="USD">2.68</Money>
</
Total>
<
ShipTo>
<
Address>
<
Name xml:lang="en">Acme</Name>
<
PostalAddress name="default">
<
DeliverTo>Joe Smith</DeliverTo>
<
DeliverTo>Mailstop M-543</DeliverTo>
<
Street>123 Anystreet</Street>
<
City>Sunnyvale</City>
<
State>CA</State>
<
PostalCode>90489</PostalCode>
<
Country isoCountryCode="US">United States</Country>
</
PostalAddress>
</
Address>
</
ShipTo>
<
BillTo>
<
Address>
<
Name xml:lang="en">Acme</Name>
<
PostalAddress name="default">
<
Street>123 Anystreet</Street>
<
City>Sunnyvale</City>
<
State>CA</State>
<
PostalCode>90489</PostalCode>
<
Country isoCountryCode="US">United States</Country>
</
PostalAddress>
</
Address>
</
BillTo>
<
Tax>
<
Money currency="USD">0.19</Money>
<
Description xml:lang="en">CA Sales Tax</Description>
</
Tax>
<
Payment>
<
PCard number="1234567890123456" expiration="1999-03-12"/>
</
Payment>
<
Comments xml:lang="en-US">Anything well formed in XML can go here.</Comments>
</
OrderRequestHeader>
<
ItemOut quantity="2" requestedDeliveryDate="1999-03-12">
<
ItemID>
<
SupplierPartID>1233244</SupplierPartID>
</
ItemID>
<
ItemDetail>
<
UnitPrice>
<
Money currency="USD">1.34</Money>
</
UnitPrice>
<
Description xml:lang="en">hello</Description>
<
UnitOfMeasure>EA</UnitOfMeasure>
<
Classification domain="SPSC">12345</Classification>
<
ManufacturerPartID>234</ManufacturerPartID>
<
ManufacturerName>foobar</ManufacturerName>
<
URL>www.foo.com</URL>
</
ItemDetail>
<
Shipping trackingDomain="FedEx" trackingId="1234567890">
<
Money currency="USD">2.5</Money>
<
Description xml:lang="en-us">FedEx 2-day</Description>
</
Shipping>
<
Distribution>
<
Accounting name="DistributionCharge">
<
Segment type="G/L Account" id="23456" description="Entertainment"/>
<
Segment type="Cost Center" id="2323" description="Western Region Sales"/>
</
Accounting>
<
Charge>
<
Money currency="USD">.34</Money>
</
Charge>
</
Distribution>
<
Distribution>
<
Accounting name="DistributionCharge">
<
Segment type="G/L Account" id="456" description="Travel"/>
<
Segment type="Cost Center" id="23" description="Europe Implementation"/>
</
Accounting>
<
Charge>
<
Money currency="USD">1</Money>
</
Charge>
</
Distribution>
<
Comments xml:lang="en-US">Anything well formed in XML can go here.</Comments>
</
ItemOut>
</
OrderRequest>
</
Request>
</
cXML>

Sorry for the scrolling – but if you’re interested in learning about cXML you have to get your eyeballs dirty.  There’s no easy way to learn cXML Order Requests – other than looking at them.  The Order Request is the actual order – the items which are being purchased.  If you have to pick a place that you really need to make sure the cXML is valid this is one of the places you’re going to put at the top of the list. 


So how do we know all these values and what they mean and what the options are?  Well it’s actually pretty simple.  Remember that 2nd line of the OrderRequest?  The one identifying it as cXML? The one that if you were writing a parser for this in XML it kept failing on and you probably just deleted that line because you couldn’t get it to work right?  (Yeah … I know who you are. ;-))


<!DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.2.019/cXML.dtd">


Well –that is probably the single most important document in your cXML.  It’s the one that tells computers where to get a copy of the DTD that you can validate the file against. It is the line that identifies the cXML as cXML and if you have deleted this line because your XML parser threw a hissy fit when it read it … you’ve just got well formed XML and it’s worthless to send to anyone as cXML.


I’m going to go on record right now and tell you that whatever your consultant that you paid a ton of money for tells you – you have to have this line.  Regardless of what your Supplier Network says or any other documentation you have says… if you are not including this line in your parse then you are not sending anyone cXML and there’s a good chance that you’re going to have errors when you connect to anyone who is cXML compliant and that’s almost everyone who adheres to this standard.


So … that is why I’m spending so much time on this subject and what a POSR is and what a POOR is and later on… what a POOM (PunchOutOrderMessage) is.


It’s also why I coded up a very short and very quick and dirty validator in the last blog update.  So if you don’t have it – go back and get that and see if you can get it running.


I included the source code so you can download a copy of Visual Studio VB Express (which is free from Microsoft at this link) and take a look at how this works.


Inside this little toy you’ll see a function I’ve borrowed from Microsoft’s MSDN samples on validation with a DTD.  I’ve named it cXML_validate – so it’s pretty easy to find.  Let’s look at it below:

Private Function cXML_validate(ByVal value As String) As Boolean
' Set the validation settings.
Dim settings As XmlReaderSettings = New XmlReaderSettings()
settings.ProhibitDtd = False
settings.ValidationType = ValidationType.DTD
AddHandler settings.ValidationEventHandler, AddressOf ValidationCallBack
cb_Success = True
' Create the XmlReader object.
Try
Dim
reader As XmlReader = XmlReader.Create(value, settings)
' Parse the file.
While reader.Read()
End While
Catch
ex As Exception
MsgBox(ex.Message)
End Try

Return
cb_Success

End Function

Pretty straightforward right?  It creates a XMLReader, it sets the settings for the reader and it has a handler that handles the ValidationCallBack for when the validation fails, and the rest is just a very simple get the file, read through the file, and if there’s an error (aside from the validationcallback) toss it. 


Now, what throws a lot of people (especially with .NET code) is that when Microsoft created the XML reader system, they assumed that it would be used for XML (silly Microsoft – what’s next?  They’re going what – create an operating system that’s used for … what it’s intended.)


Anyway… the reason why this is important is that XML and cXML are NOT the same and that very lonely line we discussed earlier uses a DTD file.  Now that DTD file has all the cool things in there you’ll need to validate the file.  Unfortunately eons ago there was a bunch of discussions on standards.  Now, some people thought that you should use a DTD file to validate a schema on an XML file and some people thought you should use a XSD file. 


I’ll cut to the chase here and simplify this for you – the end result is the people that felt DTD files should be used lost.  So Microsoft being part of the group that felt that XSD files should be used kind of created that as the process around which their XML parsers should be used.  They did consider the use of DTD files, and because of this DTD files can be used to validate a document but you need to know how to turn that on or you’re going to get an error similar to this:


image


So I’ll explain to you how you turn this feature on in the code.  If you look at the function above, there are two lines


settings.ProhibitDtd = False settings.


ValidationType = ValidationType.DTD


Now the first one – settings.ProhibitDtd=False, sets the fact that a DTD will be used in the reader and it’s okay and don’t give us that silly looking error.  The second one of course sets the validation type to DTD file. 


But there’s more because in order to do this, we need to set this property – which we do at the top of the Class, with the following property settings:

Public Property ProhibitDtd() As Boolean
Get
Return False
End Get
Set
(ByVal ProhibitDtd As Boolean)
ProhibitDtd = False
End Set
End Property

 


Yup … it’s that simple.  Just create the property so that it can be returned in the code and you’re good to go.  This believe it or not is something that completely throws a lot of devs who try to use the XMLReader to read a cXML and validate it, and it’s that simple to do.  It would I might add, help if they explained that it’s necessary to do this, but apparently that slipped someones mind I guess.


Getting back to validation… we need to do something else that you’ll find in the code, which is set the value of the callback handler to TRUE, so it will return a FALSE if the validation call back handler is triggered.  We do this because the only time it’s triggered is if there’s a validation error. 


Since we’ll be needing to pass this between the Function and the Callback – we want to add the following to the Public Properties area so the value is accessible.  We’ll call the value cb_Success and make it boolean, so it’s either a TRUE or FALSE, success or Failure.

Private cb_Success As Boolean

So we want the callback handler to hit, display the error, write that out for us, set itself to False and keep going.  Here’s the code for the validationcallback handler:

Private Sub ValidationCallBack(ByVal sender As Object, _
ByVal args As ValidationEventArgs)
'Display the validation error. This is only called on error
cb_Success = False
If
(args.Severity = XmlSeverityType.Warning) Then
RichTextBox1.AppendText("No schema found to enforce validation.")
ElseIf (args.Severity = XmlSeverityType.Error) Then
RichTextBox1.AppendText("Validation error: ")
End If

If Not
(args.Exception Is Nothing) Then ' schema validation error
RichTextBox1.AppendText("DTD Schema error (File: " + args.Exception.SourceUri + ")" + vbCrLf)
RichTextBox1.AppendText(vbCrLf)
RichTextBox1.AppendText(String.Format(vbLf & "Validation event ({0}, {1}):" & vbLf & "{2}",_
args.Exception.LineNumber, args.Exception.LinePosition, args.Message) + vbCrLf)
RichTextBox1.AppendText(args.Message.ToString + vbCrLf)
Label1.Text = "Warning"
End If
End Sub


Once again – it’s really straightforward – we first set the cb_Success value to False since we set it to TRUE before we started.  Next we want it to check for the severity level of the validation error.  If it’s a warning it generally that there’s no schema (dtd) found to enforce the validation. If this is a full blown error – well – we want the message to be of use. 


So – we then tell us where we can find the DTD file, because when an error occurs reading cXML it loads up the DTD file, which means there is a good chance that we’ll see line numbers waaaaay past anything in our cXML file.  If we are – then the error kicked back will be something that we can find in the DTD, which has been loaded already.  (To debug these errors you’ll want to download the DTD and look for the line numbers and position from this DTD … which is why we have it pull the URI for the DTD.)


Next thing we need to do is see if we can’t pull the validation error line number and position of the error within the file (remember = some errors will report within the DTD) and finally we want it to display the error message so we have that too.


Here’s a few screen shots of actual errors you’ll see:


image
(Indicates that you have a malformed or incomplete DOCTYPE header tag – most likely someone removed the DTD or the entire DOCTYPE tag.)


image 
This is kind of a confusing error message, but the gist of it is you have a Attribute or Element that is not conforming properly.  You can look up a specific tag in the DTD from the line numbers provided and see how it’s expected to be set up.


 


The best reason I’ve found for why the error messages from the validators aren’t more clear – is because of the flexibility of XML and of the actual specifications.  Microsoft often takes a bit of a bashing for error messages and code errors related to them but in fact – this is actually how the spec is designed.  Humorously enough, while researching for examples for this error I ran across this in a forum posting:


Here’s a discussion with a response from Microsoft on why you see the above error:







 Hello Michael,
This is not a bug in XmlValidatingReader nor it is a bug in IE6 or Firefox. The XML spec gives the parser a choice to error. See section 3.2.1 of the XML spec in Validity constraint: Proper Group/PE Nesting (http://www.w3.org/TR/REC-xml/#sec-element-content): "For interoperability, if a parameter-entity reference appears in a choice, seq, or Mixed construct, its replacement text SHOULD contain at least one non-blank character, and neither the first nor last non-blank character of the replacement text SHOULD be a connector (| or ,)."
Thanks,

-Helena Kupkova, Microsoft


And the reply:

Thank you for the reply.
As far as I can tell, the XML spec doesn't specify that it's an error to violate a constraint indicated by the keyword SHOULD, SHOULD NOT, RECOMMENDED, MAY, or OPTIONAL. Thus, isn't XmlValidatingReader nonconforming when it reports that test.xml is in error?

-Michael

 


As you can see – the original assumption was the error was from the XMLValidatingReader code, when in fact it’s reporting exactly what it’s supposed to – and in the spec it tells us exactly what should go there for this error, namely


"For interoperability, if a parameter-entity reference appears in a choice, seq, or Mixed construct, its replacement text SHOULD contain at least one non-blank character, and neither the first nor last non-blank character of the replacement text SHOULD be a connector (| or ,)."

And as you can see from Michaels reply … a lot of confusion gets generated by who should conform to what and the use of words like “should” and “optional” … and this is why Specs should be clear.  Because everyone has the right to their own opinion – and if given the chance they’ll use their opinion and do something silly with it just because they “think” it should be a certain way.


So – in this case Michael has an issue with the word “should” and Michael “should” realize that when the XML committee says you “should” do something it means yes… in this case you have to – even if it’s inconvenient and makes you write more code.   Lesson:  Don’t shoot the messenger – or better yet – read the specs. 


These are just a few error messages that will be generated.  Because we’re now working with the DTD instead of just treating this like some well formed XML with no rules or structure for processing behind it.  The downside to this is we now have to actually adhere to those rules (which we have to anyway when the files got processed) and not be blind and pretend they didn’t exist.


The upside to this is – our files are far more likely to process without error, they are going to process with far more efficiency since they’re valid and don’t have to be scrubbed or massaged to get the data out of them, and they are far less likely to kick back an error and not get processed at all.


But a caveats or two about what you read here and the code provided:


   - First of all – this is very simplified.  You can write validators that are capable of some amazing things.  Secondly it has errors in the code.  Well, let’s not say errors – let’s say this is the code I had to write because the code I wrote was too close to the code I wrote for someone else… and it was late when I did it.  So – some oddities in it that you can clean up – just above the Label1.test=”Warning:” in the validationcallback handler?  We don’t need that line that writes the args.message to the Richtextbox1.  It’s already done in the line above it.


Like I said – it was late when I wrote that and it’s hardly my best work.  But it does work – so feel free to edit it change it and play with it. 


This is just to get you started and I want to stress that. 


- Second of all – Not the expert on this I wish I was.  I’m good with the cXML, but I’m not with cXML.org or any official representative of it.  I have no authority beyond being someone who works with it every day and sees a lot of problems caused by invalid cXML.  In fact, almost 80% of my workload is due to cXML which will not pass validation.  And these files come from some of the biggest names in the IT industry so – don’t feel bad if you don’t “get cXML” – apparently most people don’t.  I know I certainly don’t and I repair their files for them. 


You can study the subject of eCommerce for years and still never know it all. It’s not meant to be the final word on the subject by any means.  It is literally just the beginnings of this for and should not be used to quote, refer to or otherwise say, “In this column they said…”. 


Everything here is backed by the actual cXML.org documentation or the W3, or XML.org.  Quoting me is silly when you have the big guns like those you can use. 


- Final Caveat:  One strange thing you will note…


You mayget a chuckle out of the fact that the cXML examples on cXML.org will not pass a validation using their own DTD.  There are a couple of reasons why – but the basics are that they’re written for very generalized and genericized examples and not meant to pass validation.


Well I’m about ready to turn into a pumpkin… so I’m going to leave this off for now and we’ll cover more validation errors in a later post. 


Until then… take care.

Saturday, June 20, 2009

validating PunchOut cXML pt. 1

A while back – I promised I’d write up something about a cXML validation tool… and I even showed some screen shots of one I’d been working on.  Well that tool worked so well – it now belongs to where I work so I’ve had to come up with a nice simple version to show you all here that doesn’t violate any confidentialities or agreements.

I will actually build that same kind of features here … but we’re going to take it slow and easy and work our way up.   So let’s start with why you need to validate cXML – and what you need to perform a validation.

This might seem obvious to a lot of us, but believe it or not you have no idea how many paid consultants I deal with that will argue with me that their cXML is valid when it’s missing even the most basic and common tags for even normal XML, let alone those specific to cXML, and then they will wonder why it is they can’t connect to your catalogs and process orders. <rolls eyes>

PunchOut cXML is really nothing more than a standard eCommerce transaction system protocol. 

In the first step of a PunchOut system, a PunchOutSetUpRequest (POSR) is sent to a supplier of a product.  This POSR has all the information needed to connect the two systems securely.  It is made up of three data structures or tables if you will, the Header, which contains validation information.  Who the POSR is From, who the POSR is sent To, who the POSR’s Sender is and their secure password.

The data structure looks something like this…image

 

The <From> tag contains the <Identity> of who the POSR is from.

The <To> tag contains the <Identity>, usually a DUNS number of who the transaction is being sent to (the Supplier).

The <Sender> tag contains the <Credential> <Identity> and <Credential> <SharedSecret> of who the supplier is recieving the POSR from and what sort of system they sent the POSR from found in the <UserAgent> tag.

This can be somewhat confusing as the <From> and the <Sender> are not always the same.  For this reason many systems you’ll deal with (Ariba, Oracle Supplier and Oracle Exchange for example) actually authenticate based not on the <Sender> <Identity> but on the <From> <Identity> and the <Sender> <SharedSecret>. 

The reason for this is actually pretty logical.  A Buyer, for example Acme Corporation, may utilize a 3rd party like Ariba Supplier Network or Oracle Exchange / Oracle Supplier Network to actually handle their transactions.  So the Supplier will need to authenticate based on the original sender – Acme Corporation, which has established an Identity on one of these Supplier Networks.  The Supplier network will replace the Identity and SharedSecret values with their own, and this is what is sent on to the Supplier.  So the Supplier in a PunchOut model will need to know who the actual originator is in the transaction, not the last person to touch the transaction – in the case shown here, Ariba Supplier Network.

If the Supplier authenticates only on the Sender Field they would be exchanging credentials with the Supplier Network, and not the actual originator – Acme.  So by hybridizing the systems, they authenticate using the <Identity> from the originator, and the <SharedSecret> provided by the Supplier Network (Ariba).  For this reason they use the <From> <Identity> which is the orignator, or who the POSR is from. 

In fact, many Supplier Networks (ASN, OSN, OEN) completely ignore the name of the <Sender><Identity> and you can put any value you like in there and it will still authenticate.

Since a POSR is a direct communication between the Originator / Buyer and the Seller / Supplier, and the Supplier Network is not yet involved – the Buyer and Seller must have agreed upon values to authenticate with, so they will generally use the <From> <Identity> and the <Sender> <SharedSecret>. 

imagecXML rules like these seem complicated but really can be very simple, and like all simple things if you follow very basic rules it’s very easy to work with.  Rule #1… if the file can’t be validated… you’re going to have problems.  So make sure your files validate.  To help with this I’m including a free tool written in vb.net using the free VB Express version.

I’ll get into the code for this in the next blog posting – but for now you can play around with this and get a feel for how to validate an recognize files which are good and bad against the www.cxml.org files.  (Yes…. you can get the samples for all cXML transactions at… www.cxml.org.  So go there and download the guide book and samples to play with this a bit.

 cXML Validator Tool (Zipped Format)
cXML Validator Source Code

Wednesday, April 22, 2009

all burned up…

Okay… so had a few minutes this weekend and my son had asked about how the demons do their warps in the tv series “Charmed”. Ironically enough … Andrew Kramer had on his blog this week a bit that’s very much like the old “staked” flame away from Buffy and Angel.  So this is my way of giving and unabashed plug to Andrew and his site… and I would be really evil – if I didn’t mention he’s got all kinds of updated video tools you can buy there. 

Anyway – after a bit of telling my son that these effects weren’t as hard as you might imagine led to me grabbing some old video footage… And here’s a couple examples I did in After Effects to show him how easy these effects are to do.  Very fun – and surprisingly easy – they just take time.  My only complaint is I really need to break down and get a better quality camera because it’s sad when the CG work has better quality than the original footage. 

Now – admittedly the warping / warbling warp in on this is largely to cover the fact I was too lazy to go out and shoot any new footage so I took a bit of garbage footage lying around and used that as a quickie bit for the burn effect.

A better copy of the burn – is below.  Here I’m using a simple image of a penny and you can really see how the right media really makes the effect. 

So… let’s get down to how the effect layers out – and that is really the secret to making it work, a lot of layers each one over lapping the other. Now this is explained a whole lot better in one of Andrew Kramer’s tutorials and since I don’t do tutorials – and Andrew Does I’m going to refer you to him here

imageimage

The only real twists I’m adding to this is – I don’t use any pre-comp’d smoke which he does, and I’ve simplified this up a bit so we’re not using several layers that he is.  Remember I’m doing this for just a very quick effect on some very grainy footage and Andrew’s outputting HD level.   For a lot of work (web for example) this is good enough and it’s very quick. 

image image

So – we take a simple comp shot of just the woods – and another shot of me walking in these same woods.  If you have a green screen you can do this very quick – but if you’re just using raw footage it won’t take long for you to matte the woods out – and then overlay these shots.

image

image

Now – we apply the layered burn effect which is really just a combination of linear radiant's on a texture – that is then applied with color.  As this transitions across the layer it causes it to glow.

imageimage

The next set of layers uses a similar radiant and glow effect on a texture – that we’ve boosted to a point where it’s pretty much a very jagged linear ramp that as we transition this across – gives the effect of it erasing or burning away what is below. 

image

We add over this a layer of smoke and some particles that pass over it. You can see that we need to do this on a very semi-transparency to the overlapping layers that are placed over the footage.  But that’s really how easy this effect is to pull off.  It’s not complicated – it’s just a bit of repeating the same effect with slight variations one over the top of the other, and then applying them in a set order.

Once again – you can get a great detailed video tutorial on this over at Andrew Kramer’s VideoCopilot.net site who is pretty much the definitive guy for any After Effects effect.  Any of us who do anything with video from your basic beginner to long time pros can learn a lot from him – so even if you’ve never used AE that’s the place to go if you want to learn these effects.