Note: The current release is NetBeans IDE 6.5. If you are using NetBeans IDE 6.5, see the latest version of this tutorial.
In this section, you add the WSDL file and schema file to our application. Then you modify them to interpret arrays of bytes as Images. You also adjust various parts of the application to correctly locate the schema and WSDL file. In the process, you are introduced to various tools in the IDE that help you with WSDL and Schema files.
Tutorials In This Trail
In the following procedure, you create modified WSDL and XML Schema files for the web service that you created in a previous tutorial. The modified WSDL and Schema files enable the web service and the clients that consume it to parse JPEG image data that is passed as binary data.
To modify the WSDL and Schema files:
Note: Currently the node is empty. The WSDL file and schema are generated at deployment, because you have been using default setings. Therefore this node, which would normally house them, is empty. Now that you want to interpret arrays of bytes as Images, you need to provide your own WSDL file and schema. We will put them in this node.
Right-click the wsdl node and choose New > Other. The New File wizard opens. Open the XML category and select XML Schema. Name the schema file FlowerService.xsd. Repeat Step 2, but this time from the XML category select WSDL Document. Name the file FlowerService.wsdl.You should now see the following in the wsdl node.

http://localhost:8080/FlowerService/FlowerService?WSDL
Edit the WSDL file and insert the namespace declarations. These decarations are necessary for the WSDL to be valid. Replace the lines at the beginning of the file...
<!--
Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.2-hudson-182-RC1.
-->
<!--
Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.2-hudson-182-RC1.
-->
<definitions targetNamespace="http://album.flower/" name="FlowerService">
...with the following.
<definitions xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
targetNamespace="http://album.flower/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
name="FlowerService"
xmlns:tns="http://album.flower/">
Similarly, copy the schema file into your template file. The schema file is here, by default:
http://localhost:8080/FlowerService/FlowerService?xsd=1
Edit the schema file and insert the namespace declarations. These decarations are necessary for the schema file to be valid. Replace the lines at the beginning of the file...
<!--
Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.2-hudson-182-RC1.
-->
<xs:schema version="1.0" targetNamespace="http://album.flower/">
...with the following:
<xs:schema xmlns:tns="http://album.flower/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0" targetNamespace="http://album.flower/">
Next, we will change the WSDL file so that our local schema file is referenced instead of the one that is on-line. Open the WSDL file in the Design mode, as shown below.
Expand the Types node. Right-click the Referenced Schema node.Choose Add > Import. The Add Import dialog opens.
As shown below, you can now browse to the schema file and select it.
Click OK.
Delete the other schema reference, which refers to the online schema file, which we do not want to refer to anymore, and then you will see that you can access nodes from the schema file, indicating that you have now correctly referenced it.
We need to explicitly make the application server use our own version of the WSDL file, otherwise the application server will generate its own WSDL file, from our web service's annotations.
@WebService(serviceName = "FlowerService",
wsdlLocation = "WEB-INF/wsdl/FlowerService.wsdl")
You now see the following in the web service class.

Keep all the existing elements, but add the following attributes to both.
xmime:expectedContentTypes="image/jpeg" xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
You should now see the following in the same lines.


Now that the Tester application has confirmed that images are correctly being returned, we can create our Swing client to retrieve and display them.
Note: You can find correctly modified versions of the WSDL and Schema files in the downloaded sample project. Both files are in the folder web/WEB-INF/wsdl.
To send comments and suggestions, get support, and keep informed on the latest developments on the NetBeans IDE Java EE development features, join the mailing list.
You are viewing a mobilized version of this site...
View original page here