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