Errata

Java SOA Cookbook

Errata for Java SOA Cookbook

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page 45
Venetian Blind characteristics list

The second line in the Venetian Blind characteristics' list says:

"..., and Salami Slice, in which all types are global."

But all types in Salami Slice pattern are local, not global. I think the author intention when wrote this was other than talk about "types".

David Marco  Oct 06, 2010 
Printed Page 69
Example 2-8

xs:simpleType name="Suit"
should be
xs:simpleType name="suit"

Further down there is a reference to this type, s:suit, not s:Suit.
This would not pass schema validation.

Eli Lato  Sep 08, 2011 
Printed Page 87
3rd paragraph (just after sample code)

The XmlJavaTypeAdapter annotation is misspelled (XmlTypeAdapter).

David Marco  Oct 08, 2010 
Printed Page 89
Sample code

The following comments appears to be swapped:

//create instance of schema
//create factory, add options if necessary

David Marco  Oct 08, 2010 
Printed Page 100
printSkus() method

The first line of code in the printSkus() method is unnecessary, because the 'current' variable is already passed as parameter.

David Marco  Oct 13, 2010 
Printed Page 101
Source code

The StaxIterator class does not have a main() method. The following code fix the problem:

class StaxIterator {

David Marco  Oct 13, 2010 
Printed Page 101
Source code

The StaxIterator class does not have a main() method. The following code fix the problem:

class StaxIterator {
public void find() {
//...
}

public static void main(String[] args) {
StaxIterator p = new StaxIterator();
p.find();
}
}

David Marco  Oct 13, 2010 
Printed Page 105
Source code

The 'switch' statement within the 'while' block is unnnecessary because the XMLEventReader has been filtered previously and can contain only events of type START_ELEMNT.

Furthermore, the first line within the same 'while' block could be better written as follows:

XMLEvent event = reader.nextEvent();

David Marco  Oct 13, 2010 
Printed Page 108
Source code

Variable 'xpath' is never declared.

David Marco  Oct 13, 2010 
Printed Page 109
Injection Attack, 3rd paragraph

At the end of the 3rd paragrah in the Injection Attack block, the author says:

"Imagine that your user-supplied value is 'or 1 = 1'.

but should be:

"Imagine that your user-supplied value is '6 or 1 = 1'.

David Marco  Oct 13, 2010 
Printed Page 114
First line in Solution section

First line in the solution predicates:

"Use JAXB Marshaller class and invoke its static 'marshal' method."

but this method is not static.

David Marco  Oct 14, 2010 
Printed Page 213
First line of code

The invocation of the method 'passwordHeader.setActor(...)' is duplicated.

David Marco  Oct 19, 2010 
PDF Page 236
5th paragraph

In the book: "For this web service, the WSDL is located at http://www.webservicex.net/WeatherFore
cast.asmx?wsdl. Here is the command to generate the client objects:"

After executing the steps described in this section, we should have a working soap client. However, when I try to run the example code, I got the following feedback:

"Invoking...
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Net.WebException: The request failed with the error message:
--
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php">here</a>.</p>
<hr>
<address>Apache/2.2.15 (Red Hat) Server at www.weather.gov Port 80</address>
</body></html>

--.
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at WeatherService.www.nws.noaa.gov.ndfdXML.NDFDgen(Decimal latitude, Decimal longitude, productType product, DateTime startTime, DateTime endTime, weatherParametersType weatherParameters)
at WeatherService.WeatherForecast.getData(Double latitude, Double longtitude)
at WeatherService.WeatherForecast.GetWeatherByZipCode(String ZipCode)
--- End of inner exception stack trace ---
at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(Unknown Source)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(Unknown Source)
at $Proxy29.getWeatherByZipCode(Unknown Source)
at WeatherClient.main(WeatherClient.java:32)
"

It seems to me that the web service cited in the example isn't valid anymore, albeit the WSDL still resolves correctly. The new WSDL indicated is this one: http://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php?wsdl

Could you please confirm this?

Frater QL 983  Nov 30, 2011 
Printed Page 274
Handler class's methods explanation

The method 'close()' appears with a 'boolean' return type, but should be 'void'.

David Marco  Oct 23, 2010 
Printed Page 277
Last paragraph

The phrase:

"All you have to do is attach an instance of the handler to the service proxy ..."

Should be:

"All you have to do is attach an instance of the resolver to the service proxy...".


Therefore, the next phrase:

"As long as the instance you specify implements the Handler interface or one of its subinterfaces..."

Should be something like this:

"As long as the instance you add to the handler chain implements the Handler interface or one of its subinterfaces..."

David Marco  Oct 23, 2010 
Printed Page 281
First paragraph

There is not 'printMetaData()' method at all. This method would look as follows:

private void printMetaData(MessageContext ctx) {

// Prints all the inbound http headers
Headers httpResponseHeaders =
(Headers)ctx.get(MessageContext.HTTP_RESPONSE_HEADERS);
Set<String> headerNames = httpResponseHeaders.keySet();
System.out.println("********** HEADERS:");
for(String headerName : headerNames) {
List<String> headerValues =
httpResponseHeaders.get(headerName);
System.out.println("List of headers for "
+ headerName + ": " + headerValues);
}

// Prints the response code
int httpResponseCode =
(Integer)ctx.get(MessageContext.HTTP_RESPONSE_CODE);
System.out.println("********** RESPONSE CODE: "
+ httpResponseCode);

// Prints the attachments map (further procesing
// might be required in real app)
HashMap<String, DataHandler> httpInboundAttachments =
(HashMap<String, DataHandler>)ctx
.get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS);
System.out.println("********** ATTACH: "
+ httpInboundAttachments);
}

David Marco  Oct 23, 2010 
Printed Page 281
First paragraph

For the provided 'printMetaData()' method to work, you need the class 'com.sun.xml.ws.transport.Headers' which can be found in Metro whithin the 'webservices-rt.jar' file.

David Marco  Oct 23, 2010 
Printed Page 304
Last paragraph

The text says "You can use the SAAJ @Provider annotation...". I think it should be "You can use the @WebServiceProvider annotation..."

Anonymous  Apr 26, 2010 
Printed Page 336
First code example

The value of the xs:pattern for the simple type "CardNumber" is wrong. The regular expression contains anchors(^ and $), which will not work as in other languages - there are no anchor symbols in XSD, the pattern is implicitly restricting the full string. See also
http://www.w3.org/2001/05/xmlschema-errata#e2-52

The problem shows up when recipe 5.19 is tested, cardNumber will most likely fail. To rectify use this instead in the XSD:

<xs:simpleType name="CardNumber">
<xs:restriction base="xs:string">
<xs:pattern value="(\d{4}[- ]){3}\d{4}|\d{16}" />
</xs:restriction>
</xs:simpleType>

I took out the length restrictions since the pattern restricts length anyway.


Anonymous  Oct 30, 2010 
Printed Page 369
Source code

Whitin the 'sayHello()' method, the right side of the HeaderList instantiation omits a needed cast:

HeaderList headers = (HeaderList)context.getMessageContext.get(...);

David Marco  Oct 27, 2010 
Printed Page 369
Source code

Within the 'sayHello()' method, the right side of the HeaderList instantiation omits a needed cast:

HeaderList headers = (HeaderList)context.getMessageContext.get(...);

David Marco  Oct 27, 2010 
Printed Page 396
First line of code

The annotation @WebServiceProvider should contain the attribute 'serviceName' to be reachable:

@WebServiceProvider(serviceName="JaxWsRestfulService"
...


I can't understand why in this recipe the author omits great part of the example, like the web.xml descriptor (it would like as follows):

<servlet>
<servlet-name>WSServlet</servlet-name>
<servlet-class>
com.sun.xml.ws.transport.http.servlet.WSservlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>WSServlet</servlet-name>
<url-pattern>/provider/*</url-pattern>
</servlet-mapping>

Likewise, it's worth to note that the above mapping is unnecessary at all in Glassfish (at least the example is fully functional without it): simply get out the '/provider/' path from the url of the service.

David Marco  Nov 03, 2010 
Printed Page 414
Second line of code

The annotation @ProduceMime is wrong. The correct annotation is:

@Produces(MediaType.TEXT_HTML)
...

David Marco  Nov 03, 2010 
Printed Page 641
Paragraph entitled "Discussion"

Sentance is
"The WS-I Basic Profile covers standards, such as SOAP, WS-Addressing, MTOM, XOP, and so forth..."

The solution given specifically states "Follow the guidelines of the WS-I Basic Profile 1.1."

WS-Addressing is not part of WS-I Basic Profile 1.1 but it is part of the 1.2 specification.

I found that mentioning the WS-Addressing standard as being part of WS-I Basic Profile but without being specific about which version was required to be misleading and confusing. It would be an improvement if the discussion section constrained itself to discussing 1.1 of the profile for clarity.

Simon Bird  Sep 22, 2010