What is the difference between import and include in WSDLs?
The difference between the include element and the import element is that the import element allows references to schema components from schema documents with different target namespaces and the include element adds the schema components from other schema documents that have the same target namespace (or no specified target namespace) to the containing schema. In short, the import element allows you to use schema components from any schema; the include element allows you to add all the components of an included schema to the containing schema.
References:
1. IBM Web Services Programming Tips
2. Microsoft notes on import
3. XML Schema Spec Part 1
Some simple bits and pieces about Software Architecture. Generally, a JVM is somewhere...
Monday, April 25, 2011
Those any and anyAttibute elements?
When are the any and anyAttribute tags used in a schema?
Well let's start with the any. Ok, let's say you want to write a schema for sending messages but you want to make it flexible. You want to define the message envelope but the structure of the message payload is unknown to the system. Here's how you'd do it.
This means the message must have a Date, a Sender and any content.
Here's an example message:
The any tag can be further customised with attributes such as minOccurs and maxOccurs.
Now for that fella?
anyAttribute is very similar except it works on attributes.
For example:
Allows the following XML
References:
1. The XSD schema standard
Well let's start with the any. Ok, let's say you want to write a schema for sending messages but you want to make it flexible. You want to define the message envelope but the structure of the message payload is unknown to the system. Here's how you'd do it.
This means the message must have a Date, a Sender and any content.
Here's an example message:
The any tag can be further customised with attributes such as minOccurs and maxOccurs.
Now for that
anyAttribute is very similar except it works on attributes.
For example:
Allows the following XML
References:
1. The XSD schema standard
What are the differences between JAXB 1.0 and JAXB 2.0
What are the differences between JAXB 1.0 and JAXB 2.0?
References: http://javaboutique.internet.com/tutorials/jaxb/index3.html
- JAXB 1.0 only requires JDK 1.3 or later. JAXB 2.0 requires JDK 1.5 or later.
- JAXB 2.0 makes use of generics and thus provides compile time type safety checking thus reducing runtime errors.
- Validation is only available during marshalling in JAXB 1.0. Validation is also available during unmarshalling in JAXB 2.0.
- Termination occurs in JAXB 1.0 when a validation error occurs. In JAXB 2.0 custom ValidationEventHandlers can be used to deal with validation errors.
- JAXB 2.0 uses annotations and supports bi-directional mapping.
- JAXB 2.0 generates less code.
- JAXB 1.0 does not support key XML Schema components like
anyAttribute, key, keyref
, andunique
. It also does not support attributes likecomplexType.abstract, element.abstract, element.substitutionGroup, xsi:type, complexType.block, complexType.final, element.block, element.final, schema.blockDefault
, andschema.finalDefault
. In version 2.0, support has been added for all of these schema constructs.
References: http://javaboutique.internet.com/tutorials/jaxb/index3.html
XPath Example
XPath is a query language for XML defined by the W3C. It can:
An example please?
No problem. Let's start with some XML.
The XML represents some books in a library. Suppose you wish to query this XML to see the names of the books that Brian Smith has wrote. Now you don't want the hassle of converting the XML to book objects and filtering through them yourself just to get the names. So you decide to use XPath. Here's how you'd do it.
Other points worth pointing out:
- Select nodes in a XML document
- Compute values from the content of an XML document.
An example please?
No problem. Let's start with some XML.
The XML represents some books in a library. Suppose you wish to query this XML to see the names of the books that Brian Smith has wrote. Now you don't want the hassle of converting the XML to book objects and filtering through them yourself just to get the names. So you decide to use XPath. Here's how you'd do it.
Other points worth pointing out:
- An XPath expression is not thread-safe and not reentrant. In other words, it is the application's responsibility to make sure that one
XPathExpression
object is not used from more than one thread at any given time, and while theevaluate
method is invoked, applications may not recursively call theevaluate
method. - XPathConstants.NODESET is a XPath 1.0 type.
- There are some tools out there to help you figure out what your XPath expression should be. For example XmlToolBox
Probabilities
Every so often an understanding of mathematical probability is needed when programming. Let's cover some basics.
Factorials
How many possible ways are there to arrange the 26 letters of the alphabet?
Well, there are 26 possible ways to arrange the first letter, 25 possible ways to arrange the second letter, ... 1 possible ways to arrange the last letter letter.
This is equal to 26 * 25 * 24 * ... * 1. This mathematical sequence is called a factorial. And can be written as 26! The answer to 26! is 403291461126605635584000000 -- wow.
Selections
We are often concerned with particular selections of objects rather than all objects. For example, suppose we have three letters: A, B, C. It is possible to select two letters 6 different ways: AB, BA, AC, CA, BC, CB. When order matters it the selection is a permutation. When order does not matter it is said to be a combination. Hence, for the same three letters (A, B, C) there may be 6 permutations but only 3 combinations: AB, AC, BC.
Combinations
In general, the number of combinations of r objects from n objects is given by:
In general, the number of permutations of r objects from n objects is given by:
Factorials
How many possible ways are there to arrange the 26 letters of the alphabet?
Well, there are 26 possible ways to arrange the first letter, 25 possible ways to arrange the second letter, ... 1 possible ways to arrange the last letter letter.
This is equal to 26 * 25 * 24 * ... * 1. This mathematical sequence is called a factorial. And can be written as 26! The answer to 26! is 403291461126605635584000000 -- wow.
Selections
We are often concerned with particular selections of objects rather than all objects. For example, suppose we have three letters: A, B, C. It is possible to select two letters 6 different ways: AB, BA, AC, CA, BC, CB. When order matters it the selection is a permutation. When order does not matter it is said to be a combination. Hence, for the same three letters (A, B, C) there may be 6 permutations but only 3 combinations: AB, AC, BC.
Combinations
In general, the number of combinations of r objects from n objects is given by:
n C r = n! / (n - r)! r!
PermutationsSo in our example above, to calculate the number of combinations of 2 letters our of the 3 it would be: 3 C 2 = 3! / (3 - 2)! 2! = 6 / 1 * 2 = 3.
In general, the number of permutations of r objects from n objects is given by:
n P r = n! / (n - r)!
So in our example above, to calculate the number of permutations of 2 letters our of the 3 it would be: 3 P 2 = 3! / (3 - 2)! = 6 / 1 = 6.
Sunday, April 17, 2011
SMTP
Simple Mail Transfer Protocol (SMTP) is text based protocol for sending emails across the Internet. It grew for the need for different systems needing to communicate with each other.
A SMTP transactions consists of three command / reply sequences. They are:
The Server responds to these commands uses status codes. The responses are positive (2xx reply codes) or negative. Negative replies can be permanent (5xx codes) or transient (4xx codes)
What is the difference between SMTP and POP and IMAP?
SMTP is really for sending messages. It cannot pull messages from a remote server on demand. You wanna read those messages sent to you that are on your email server. You need to use either the Post Office Protocol (POP) or Internet Message Access Protocol (IMAP).
So you wanna try it?
Ok, so you're sick of using email tools such as outlook for sending email messages. You wanna send your own messages?
It is possible to have Web Services over SMTP instead of HTTP. But it's more complex. Why? Because SMTP does not provide much flexibility to responses for requests. With HTTP a SOAP request message can be put into the HTTP message body. Similar a SOAP message can be put in the HTTP message body for a response. SMTP allows a SOAP message to be easily attached to the request. But not the response. A separate SMTP is required for the response.
So why why why would you ever want to use SMTP for sending SOAP messages? It might be:
References:
A SMTP transactions consists of three command / reply sequences. They are:
- MAIL command. Establishes return address.
- RCPT command. Establishes recipient of message.
- DATA content of the message.
The Server responds to these commands uses status codes. The responses are positive (2xx reply codes) or negative. Negative replies can be permanent (5xx codes) or transient (4xx codes)
What is the difference between SMTP and POP and IMAP?
SMTP is really for sending messages. It cannot pull messages from a remote server on demand. You wanna read those messages sent to you that are on your email server. You need to use either the Post Office Protocol (POP) or Internet Message Access Protocol (IMAP).
So you wanna try it?
Ok, so you're sick of using email tools such as outlook for sending email messages. You wanna send your own messages?
- Open a command prompt.
- Type "telnet
25". - Talk to the server using SMTP.
It is possible to have Web Services over SMTP instead of HTTP. But it's more complex. Why? Because SMTP does not provide much flexibility to responses for requests. With HTTP a SOAP request message can be put into the HTTP message body. Similar a SOAP message can be put in the HTTP message body for a response. SMTP allows a SOAP message to be easily attached to the request. But not the response. A separate SMTP is required for the response.
So why why why would you ever want to use SMTP for sending SOAP messages? It might be:
- You cannot use HTTP because of firewalls
- The request / response model isn't desired by your application. You might just want something like publish / subscribe
- You web services are take a long time to run and you don't want situations where HTTP will time out on you.
References:
Saturday, April 16, 2011
Very simple AJAX example
Ok, so you're embarrassed about your lack of knowledge of WEB 2.0 and in particular Rich Clients and that little place in the Netherlands called... AJAX. Well have no fear! You will now learn the basics of AJAX.
Let's start with a requirement. You are required to update part of your web page and (only part of your web page) asynchronously. When? Well when a button called 'Update with AJAX' is clicked!
And what are you required to update it to? The contents of a file that reside on your server.
Ok let's look at the solution.
Now let's look at the salient points here:
Let's start with a requirement. You are required to update part of your web page and (only part of your web page) asynchronously. When? Well when a button called 'Update with AJAX' is clicked!
And what are you required to update it to? The contents of a file that reside on your server.
Ok let's look at the solution.
Simple Ajax / Javascript Example
Very simple Javascript / Ajax Example
This page shows some very simple JavaScript / Ajax in action!
This will text be updated!
Now let's look at the salient points here:
- The HTML is pretty simple. There is a paragraph with the "id".
This is the paragraph that will be updated when the Ajax Update
button is pressed. - The Javascript function loadDoc() is defined in the HTML header.
- The loadDoc() function creates a XMLHttpRequest object (or an ActiveXObject for
those annoying browsers!) - The XMLHttpRequest is pretty cool. This is what facilitates the AJAX request.
It has a event property onreadystatechange. When this property an anonymous
function will execute. - The anonymous function, checks a property readyState. When this property is 4 it means that the server has finished the request and the response is ready.
- When the response is ready, the function checks another property responseText
which contains the response from the server. It updates the paragraph with the response.
So what actually sends the request?- The open API sets up the request. It states what type a request (Get, parameter 1), the URL / URI (ajax_info.txt, parameter 2) and that the request should be
asynchronous (false, parameter 3). - The send API sends the request. In this case, no parameter is included.
This means the the client sends no request to the Server. It can if it wants to. It would simply include a parameter in the send() API which is the data the client will
send to the server.
Now to get this working all you need is this file and a file named ajax_info.txt on the same Server! Enjoy! - The open API sets up the request. It states what type a request (Get, parameter 1), the URL / URI (ajax_info.txt, parameter 2) and that the request should be
Friday, April 15, 2011
Tidying up your file system!
Ok, so no matter how much disk space you have, you will inevitably run out. Time to see what files you can delete. Well it's not always so easy to figure out where the largest files that are gobbling up your disk are. Why? Because Windows Explorer does not show the size of folders.
You could have a Virtual Disk tucked away in a folder within a folder from a training course two years ago but it's not always so easy to find!
Now, you could go old skool open up a cmd box and type > dir /s. This will list every single folder and the total file size.
However, unless you have very folders (unlikely) and very few files (more unlikely) this is difficult to read.
Even, dir /s /p won't get you that far!
What you need is what Windows Explorer should give you but doesn't. You need to be able to see all your folders visually and see who's hogging the juice.
There are many tools out on the web that will help out here. I recommend WinDirStat. It's free, simple to use and presents everything you need to know after quickly scanning your disk.
You could have a Virtual Disk tucked away in a folder within a folder from a training course two years ago but it's not always so easy to find!
Now, you could go old skool open up a cmd box and type > dir /s. This will list every single folder and the total file size.
However, unless you have very folders (unlikely) and very few files (more unlikely) this is difficult to read.
Even, dir /s /p won't get you that far!
What you need is what Windows Explorer should give you but doesn't. You need to be able to see all your folders visually and see who's hogging the juice.
There are many tools out on the web that will help out here. I recommend WinDirStat. It's free, simple to use and presents everything you need to know after quickly scanning your disk.
Monday, April 4, 2011
Javascript example!
Would you like a very simple example of Javascript in action? No problem. Let's say you have a page and when you click a button, you'd like to execute a Javascript function to update some text in the page to display the current date / time. Now first let's see that in action!
Just press the button...
Now the source code...
Now here are the salient points:
And the source code for this baby...
Just press the button...
This will be updated with the date and current time!
Now the source code...
This will be updated with the current date and time!
Now here are the salient points:
- The Javascript function is called displayDate() and this is defined in the head.
- The paragraph in the html page is given the id=demo.
- The Javascript function gets a handle on the demo paragraph using the DOM APIs
- The Javascript function updates the paragraph using the innerHtml API.
And the source code for this baby...
Subscribe to:
Posts (Atom)