Feb 27 2008

Creating SOAP Web Services with NetBeans 6

Published by Siegfried Bolz at 10:37 pm under Java, NetBeans, web services



In this blog i will show you, how easily you can create Web Services with NetBeans 6. In further postings i will discuss how to manipulate the SOAP Message before the Web Service Operation is called.

For this example i am using JAX-WS 2.1 with NetBeans 6.0 .


Web Services Description Language (WSDL)

There are many ways how to get starting with Web Services. One variant is beginning with the creation of the WSDL. First, you must know what the Web Service should do. You have to consider what is the input and output of each Web Service Operation. In our example we have only one Operation, named as “getcalculateValues“. The input are two numbers, the result is only the sum of both.

Create these two files for our example:

webservices.wsdl

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns:ns1="soapwebservices.jdevelop.eu" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="http://schemas.xmlsoap.org/soap/encoding/" name="SOAPWebServices" targetNamespace="soapwebservices.jdevelop.eu">
	<types>
		<xsd:schema>
			<xsd:import namespace="soapwebservices.jdevelop.eu" schemaLocation="webservices.xsd"/>
		</xsd:schema>
	</types>
	<message name="calculateValues">
		<part name="calculateValues" element="ns1:calculateValues"/>
	</message>
	<message name="calculateValuesResponse">
		<part name="calculateValuesResponse" element="ns1:calculateValuesResponse"/>
	</message>
	<portType name="SOAPWebServices">
		<operation name="getCalculateValues">
			<input message="ns1:calculateValues"/>
			<output message="ns1:calculateValuesResponse"/>
		</operation>
	</portType>
	<binding name="SOAPWebServicesPortBinding" type="ns1:SOAPWebServices">
		<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
		<operation name="getCalculateValues">
			<soap:operation soapAction="urn:http://blog.jdevelop.eu/services/getCalculateValues"/>
			<input>
				<soap:body use="literal"/>
			</input>
			<output>
				<soap:body use="literal"/>
			</output>
		</operation>
	</binding>
	<service name="SOAPService">
		<port name="WebServices" binding="ns1:SOAPWebServicesPortBinding">
			<soap:address location="http://blog.jdevelop.eu:80/services"/>
		</port>
	</service>
</definitions>


webservices.xsd

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema xmlns:ns1="http://blog.jdevelop.eu/soapwebservices.xsd" xmlns:tns="soapwebservices.jdevelop.eu" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="soapwebservices.jdevelop.eu" version="1.0">
	<xs:element name="calculateValues">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="value1" type="xs:decimal"/>
				<xs:element name="value2" type="xs:decimal"/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="calculateValuesResponse">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="result" type="xs:decimal"/>
				<xs:element name="errormessage" type="xs:string" minOccurs="0"/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
</xs:schema>



Create the NetBeans application

Start your NetBeans 6 and create a new “Web Application” -Project.
NetBeans new Web Application Project


Name it “SOAPWebServices“, clear the “Context Path” and click “Finish“.
NetBeans Web Application


Now goto “File->New File->Web Services” and choose “Web Service from WSDL“.
If this menu is missing, you need to install the “Web Service Plugin” (Tools->Plugins->Available Plugins).
NetBeans Web Service from WSDL


Enter the Web Service Name “ServiceImpl“, use “eu.jdevelop.soapwebservices.service” as
the package-name and browse to the file “webservices.wsdl“, which you have created in the previous step.
NetBeans New Web Service from WSDL


After pressing “Finish”, you will see this screen:
NetBeans Web Service Overview


It’s now time to change the url-pattern. Open the file “sun-jaxws.xml” and exchange the url-pattern with “/soapwebservices“.
NetBeans sun-jaxws.xml before

NetBeans sun-jaxws.xml after


Do the same with the file “web.xml“.
NetBeans web.xml before

NetBeans web.xml after


Go ahead to the file “index.jsp” and insert in the “body“-tag:

<jsp:forward page="soapwebservices"></jsp:forward>

NetBeans jsp-forwarding


Your Dummy-Web Service is now ready for testing. Rightclick on the projectname and choose “Clean and Build“.
NetBeans clean and build project


After that, click on “run“.
NetBeans run project


Browse to the url “http://localhost:8084” to see the result.
NetBeans running web service


You can see the WSDL and the XML-Schema.
NetBeans running WSDL

NetBeans running xml schema


It’s now time to insert the business-logic. Add the following java classes to recieve this package-structure:
NetBeans project package structure


ServiceImpl.java

package eu.jdevelop.soapwebservices.service;

import eu.jdevelop.soapwebservices.CalculateValues;
import eu.jdevelop.soapwebservices.CalculateValuesResponse;
import eu.jdevelop.soapwebservices.SOAPWebServices;
import eu.jdevelop.soapwebservices.wrapper.impl.CalculateValuesWrapper;
import javax.jws.WebService;

/**
 * This is the Service-Implementation of the Web Service. Here are the
 * operations which can be called from web clients.
 *
 * @author Siegfried Bolz
 */
@WebService(serviceName = "SOAPService", portName = "WebServices", endpointInterface = "eu.jdevelop.soapwebservices.SOAPWebServices", targetNamespace = "soapwebservices.jdevelop.eu", wsdlLocation = "WEB-INF/wsdl/ServiceImpl/webservices.wsdl")
public class ServiceImpl implements SOAPWebServices {

    public CalculateValuesResponse getCalculateValues(CalculateValues calculateValues) {

        try {
            CalculateValuesWrapper wrapper = new CalculateValuesWrapper();
            return wrapper.getResult(calculateValues);

        } catch (Exception x) {
            throw new IllegalStateException(x);
        }
    }

} // .EOF



ILogic.java

package eu.jdevelop.soapwebservices.logic;

/**
 * Use this interface to create logic-implementations for
 * each web service operation.
 *
 * @author Siegfried Bolz
 */
public interface ILogic<t, V> {

    public T doAction(V var)
            throws Exception;
} // .EOF



CalculateValuesLogic.java

package eu.jdevelop.soapwebservices.logic.impl;

import eu.jdevelop.soapwebservices.CalculateValues;
import eu.jdevelop.soapwebservices.CalculateValuesResponse;
import eu.jdevelop.soapwebservices.logic.ILogic;
import java.math.BigDecimal;

/**
 * This implementation is normaly used for executing operations.
 * Here we calculate some values.
 *
 * @author Siegfried Bolz
 */
public class CalculateValuesLogic implements ILogic<calculateValuesResponse, CalculateValues>{

    public CalculateValuesResponse doAction(CalculateValues var) throws Exception {

        CalculateValuesResponse response = new CalculateValuesResponse();

        try {
            /**
             * Simple addition of two values
             */
            BigDecimal value1 = var.getValue1();
            BigDecimal value2 = var.getValue2();

            double sum = value1.doubleValue() + value2.doubleValue();

            response.setResult(BigDecimal.valueOf(sum));

        } catch (Exception x) {
            /**
             * On errors, return a valid bean with values. Do not send null!
             */
            CalculateValuesResponse errorResponse = new CalculateValuesResponse();
            errorResponse.setResult(BigDecimal.valueOf(0.0));
            errorResponse.setErrormessage("An error has occurred!");
            return errorResponse;
        }

        return response;
    }

} // .EOF



IWrapper.java

package eu.jdevelop.soapwebservices.wrapper;

/**
 * Use this interface to create wrapper-implementations for
 * each web service operation.
 *
 * @author Siegfried Bolz
 */
public interface IWrapper<t, V> {

    public T getResult(V var)
            throws Exception;
} // .EOF



CalculateValuesWrapper.java

package eu.jdevelop.soapwebservices.wrapper.impl;

import eu.jdevelop.soapwebservices.CalculateValues;
import eu.jdevelop.soapwebservices.CalculateValuesResponse;
import eu.jdevelop.soapwebservices.logic.impl.CalculateValuesLogic;
import eu.jdevelop.soapwebservices.wrapper.IWrapper;

/**
 * The wrapper calls the logic-implementation. Exchange or modify
 * the wrapper if you want to use other logic-implementations.
 *
 * @author Siegfried Bolz
 */
public class CalculateValuesWrapper implements IWrapper<calculateValuesResponse, CalculateValues>{

    public CalculateValuesResponse getResult(CalculateValues var) throws Exception {
        CalculateValuesLogic logic = new CalculateValuesLogic();
        return logic.doAction(var);
    }

} // .EOF



When you are finished, you should see something similar in the Files-View:
NetBeans file view


Testing

Download, install and start “soapui” from http://www.soapui.org. Import the soapui-projectfile “SOAPWebServices-soapui-project.xml” (located in the example).
Open “Request1” and submit the request (click the green arrow).
running soapui with an request-example


Congratulations, your Web Service is now running


Possible Problem

If you get the error:

Caused by: java.lang.LinkageError: JAXB 2.0 API is being loaded from the bootstrap classloader, but this RI (from jar: file:/C:/temp/SOAPWebServices/build/web/WEB-INF/lib/jaxb-impl.jar!/com/sun/xml/bind/v2/model/impl/ModelBuilder.class) needs 2.1 API. Use the endorsed directory mechanism to place jaxb-api.jar in the bootstrap classloader. (See http://java.sun.com/j2se/1.5.0/docs/guide/standards/)

This means, that your JAX-WS version is newer than the JAXB 2.0 and JAX-WS 2.0 versions, which are part of JDK 6.
To solve this problem, just copy all JARs from $NETBEANS_HOME/java1/modules/ext/jaxws21/api/ to $TOMCAT_INSTALL_DIR/endorsed/ (the directory “endorsed” must be created if it doesn’t exist).
NetBeans endorsed error with jax-ws

For further informations, look at http://wiki.netbeans.org/FaqEndorsedDirTomcat


Downloads

NetBeans 6 Project: download

Technorati Tags: , , ,


62 Responses to “Creating SOAP Web Services with NetBeans 6”

  1. [...] Creating SOAP Web Services with NetBeans 6 — Another Random Developer Blog, 2/27 Developer Siegfried Boltz posts a detailed tutorial [...]

  2. Ucheon 20 Mar 2008 at 6:36 pm

    Hi, this is interesting. I wondering how I can manipulate the SOAP Header. I am doing some security stuff with SAML, I need to add the nodes to SOAP header and manipulate them in both the client side and server.

  3. Jonathanon 31 Mar 2008 at 1:20 am

    Hello,

    I’m almost done running this tutorial but I’m stack at the part

    “Download, install and start “soapui” from http://www.soapui.org. Import the soapui-projectfile “SOAPWebServices-soapui-project.xml” (located in the example). ”

    Where exactly is this xml file?

    Other than that, everything up to that point has been good.

    Any comments would be appreciated.

    Thanks.

  4. Siegfried Bolzon 31 Mar 2008 at 7:38 am

    Hello Jonathan,

    if you extract the file “soapwebservices.zip”, the SOAPUI-File is located in the directory “/soapui” .

    best regards
    Siegfried

  5. Tuan Dangon 02 Apr 2008 at 6:04 am

    I got the same problem. Unfortunately, I couldn’t locate the file “soapwebservices.zip” you mentioned. Are we supposed to download it somewhere?

    Thanks for your help.

  6. Siegfried Bolzon 02 Apr 2008 at 7:54 am

    Hello Tuan,
    at the end of this blog-entry is the download-link located.
    http://blog.jdevelop.eu/downloads/soapwebservices/soapwebservices.zip

  7. Tuan Dangon 02 Apr 2008 at 5:43 pm

    Thank you so much. It works now.

  8. Arne Knorron 18 Apr 2008 at 1:53 pm

    Hello Siegfried,
    Nice article here, it worked fine for me. But now I am at the point where I have to add Security and RM to my WS. With a WS generated bottom up it works fine but I have some problems adding Security and RM to the WS generated from WSDL. I click the WS in Netbeans, check the Security and RM properties, but the dont show up in the WSDL on the server after deploying. Did you have any similar problem and how did you sove it?

    Cheers
    Arne

  9. Siegfried Bolzon 18 Apr 2008 at 6:48 pm

    Hello Arne,
    my experience in adding Security is, that it is only working with GlassFish v2 (if you are using the NetBeans-features). But i haven’t done too much with Security (using VPN is easier). I am planning to do more research in this area.

    Regards,
    Siegfried

  10. Susovan Ghoshon 30 Apr 2008 at 11:38 am

    Hello Siegfried,

    I am a raw beginner in NetBeans. Could you please tell me which files to customize if I want to send a WORD as the request and then receive the charecters of the word in an ARRAY in the response??

    Thanks in advance.
    Susovan

  11. Siegfried Bolzon 30 Apr 2008 at 1:00 pm

    Hello Susovan,
    first you have to modify the WSDL with the Schema. Rebuild the project to generate new Beans. After that you have to modify the ServiceImpl.java .

    Take a look on “Table 1” at http://java.sun.com/developer/technicalArticles/WebServices/high_performance/ to see which Primitives are possible with JAX-WS 2.0

  12. Mirzaon 07 May 2008 at 10:59 am

    Hi Siegfried,

    I was trying to run you example but I stuck after importing WSDL file. I managed to generate classes and create the blue backgound with the method name but failed to compile it.

    I have got the following error during the compilation:

    javac -d D:\Documents and Settings\mirza.jahic\My Documents\NetBeansProjects\WebServiceApp\build\generated\wsimport\binaries -classpath C:\Program Files\Java\jdk1.5.0_15\lib\tools.jar;C:\bea\weblogic92\server\lib\weblogic.jar;C:\bea\weblogic92\common\lib\apache_xbean.jar;C:\bea\weblogic92\server\lib\schema\weblogic-container-binding.jar;C:\bea\weblogic92\server\lib\schema\weblogic-domain-binding.jar;C:\bea\weblogic92\server\lib\schema\diagnostics-binding.jar;C:\bea\weblogic92\server\lib\schema\diagnostics-image-binding.jar;C:\bea\weblogic92\server\lib\wlcipher.jar;C:\bea\weblogic92\server\lib\jsafe.jar;C:\bea\weblogic92\server\lib\webservices.jar;C:\bea\weblogic92\server\lib\xmlx.jar;C:\bea\weblogic92\server\lib\ojdbc14.jar;C:\bea\weblogic92\server\lib\jconn2.jar;C:\bea\weblogic92\server\lib\jconn3.jar;C:\bea\weblogic92\server\lib\jConnect.jar;C:\bea\weblogic92\server\lib\cssjdkutils.jar;C:\bea\weblogic92\server\lib\cssapi.jar;C:\bea\weblogic92\server\lib\cssimpl.jar;C:\bea\weblogic92\server\lib\engapi.jar;C:\bea\weblogic92\server\lib\engimpl.jar;C:\bea\weblogic92\server\lib\EccpressoAsn1.jar;C:\bea\weblogic92\server\lib\EccpressoCore.jar;C:\bea\weblogic92\server\lib\EccpressoJcae.jar;C:\bea\weblogic92\server\lib\ant\ant.jar;C:\bea\weblogic92\server\lib\ant\ant-nodeps.jar;C:\bea\weblogic92\server\lib\ant\ant-antlr.jar;C:\bea\weblogic92\server\lib\ant\ant-jakarta-bcel.jar;C:\bea\weblogic92\server\lib\ant\ant-junit.jar;C:\bea\weblogic92\server\lib\ant\ant-vaj.jar;C:\bea\weblogic92\server\lib\ant\ant-apache-bsf.jar;C:\bea\weblogic92\server\lib\ant\ant-jakarta-log4j.jar;C:\bea\weblogic92\server\lib\ant\ant-launcher.jar;C:\bea\weblogic92\server\lib\ant\ant-weblogic.jar;C:\bea\weblogic92\server\lib\ant\ant-apache-resolver.jar;C:\bea\weblogic92\server\lib\ant\ant-jakarta-oro.jar;C:\bea\weblogic92\server\lib\ant\ant-netrexx.jar;C:\bea\weblogic92\server\lib\ant\ant-xalan1.jar;C:\bea\weblogic92\server\lib\ant\ant-commons-logging.jar;C:\bea\weblogic92\server\lib\ant\ant-jakarta-regexp.jar;C:\bea\weblogic92\server\lib\ant\ant-xalan2.jar;C:\bea\weblogic92\server\lib\ant\ant-commons-net.jar;C:\bea\weblogic92\server\lib\ant\ant-javamail.jar;C:\bea\weblogic92\server\lib\ant\ant-starteam.jar;C:\bea\weblogic92\server\lib\ant\ant-xslp.jar;C:\bea\weblogic92\server\lib\ant\ant-contrib-1.0b1.jar;C:\bea\weblogic92\server\lib\ant\ant-jdepend.jar;C:\bea\weblogic92\server\lib\ant\ant-stylebook.jar;C:\bea\weblogic92\server\lib\ant\ant-icontract.jar;C:\bea\weblogic92\server\lib\ant\ant-jmf.jar;C:\bea\weblogic92\server\lib\ant\ant-swing.jar;C:\bea\weblogic92\server\lib\ant\ant-jai.jar;C:\bea\weblogic92\server\lib\ant\ant-jsch.jar;C:\bea\weblogic92\server\lib\ant\ant-trax.jar;C:\bea\weblogic92\server\lib\ant\jakarta-oro-2.0.7.jar;C:\bea\weblogic92\server\lib\ant\commons-net-1.1.0.jar;C:\bea\weblogic92\server\lib\wlbase.jar;C:\bea\weblogic92\server\lib\wlutil.jar;C:\bea\weblogic92\server\lib\wlsqlserver.jar;C:\bea\weblogic92\server\lib\wldb2.jar;C:\bea\weblogic92\server\lib\wlsybase.jar;C:\bea\weblogic92\server\lib\wloracle.jar;C:\bea\weblogic92\server\lib\wlinformix.jar;C:\bea\weblogic92\server\lib\wlw-langx.jar;C:\bea\weblogic92\javelin\lib\javelinx.jar;C:\bea\weblogic92\javelin\lib\bcel-5.1.jar;C:\bea\weblogic92\common\lib\wlw-util.jar;C:\bea\weblogic92\server\lib\xbean.jar;C:\bea\weblogic92\server\lib\logkit\logkit.jar;C:\bea\weblogic92\common\lib\pdev.jar;C:\bea\weblogic92\common\lib;C:\bea\weblogic92\common\lib\3rdparty.jar;C:\bea\weblogic92\common\lib\plugin-wizard.jar;C:\bea\weblogic92\common\lib\comdev.jar;C:\bea\weblogic92\common\lib\wizard.jar;C:\bea\weblogic92\common\lib\plugin.jar;C:\bea\weblogic92\common\lib\oxy-cci.jar;C:\bea\weblogic92\common\lib\config.jar;C:\bea\weblogic92\common\lib\wlw-plaf.jar;C:\bea\weblogic92\common\lib\upgrade\common-plugin.jar;C:\bea\weblogic92\common\lib\jython.jar;C:\bea\weblogic92\server\lib\debugging.jar;C:\bea\weblogic92\server\lib\wlw-system.jar;C:\bea\weblogic92\server\lib\jcom.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\activation.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\FastInfoset.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\http.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\api\jaxb-api.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\jaxb-impl.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\jaxb-xjc.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\api\jaxws-api.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\jaxws-rt.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\saaj-impl.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\sjsxp.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\resolver.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\stax-ex.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\streambuffer.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\jaxws-tools.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\api\jsr173_api.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\api\jsr181-api.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\api\jsr250-api.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\api\saaj-api.jar -Xbootclasspath/p:C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\api\jaxws-api.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\api\jaxb-api.jar D:\Documents and Settings\mirza.jahic\My Documents\NetBeansProjects\WebServiceApp\build\generated\wsimport\service\eu\jdevelop\soapwebservices\CalculateValues.java D:\Documents and Settings\mirza.jahic\My Documents\NetBeansProjects\WebServiceApp\build\generated\wsimport\service\eu\jdevelop\soapwebservices\CalculateValuesResponse.java D:\Documents and Settings\mirza.jahic\My Documents\NetBeansProjects\WebServiceApp\build\generated\wsimport\service\eu\jdevelop\soapwebservices\ObjectFactory.java D:\Documents and Settings\mirza.jahic\My Documents\NetBeansProjects\WebServiceApp\build\generated\wsimport\service\eu\jdevelop\soapwebservices\SOAPService.java D:\Documents and Settings\mirza.jahic\My Documents\NetBeansProjects\WebServiceApp\build\generated\wsimport\service\eu\jdevelop\soapwebservices\SOAPWebServices.java D:\Documents and Settings\mirza.jahic\My Documents\NetBeansProjects\WebServiceApp\build\generated\wsimport\service\eu\jdevelop\soapwebservices\package-info.java
    D:\Documents and Settings\mirza.jahic\My Documents\NetBeansProjects\WebServiceApp\build\generated\wsimport\service\eu\jdevelop\soapwebservices\SOAPWebServices.java:35: cannot find symbol
    symbol : method partName()
    location: @interface javax.jws.WebParam
    @WebParam(name = “calculateValues”, targetNamespace = “soapwebservices.jdevelop.eu”, partName = “calculateValues”)
    D:\Documents and Settings\mirza.jahic\My Documents\NetBeansProjects\WebServiceApp\build\generated\wsimport\service\eu\jdevelop\soapwebservices\SOAPWebServices.java:33: cannot find symbol
    symbol : method partName()
    location: @interface javax.jws.WebResult
    @WebResult(name = “calculateValuesResponse”, targetNamespace = “soapwebservices.jdevelop.eu”, partName = “calculateValuesResponse”)
    2 errors
    compilation failed, errors should have been reported
    D:\Documents and Settings\mirza.jahic\My Documents\NetBeansProjects\WebServiceApp\nbproject\jaxws-build.xml:24: wsimport failed
    BUILD FAILED (total time: 33 seconds)

    I’m using NetBeans 6.0.1 and JAX-WS 2.1.

    Am I missing some jar file maybe or similar?

    Otherwise, I think that the article is great and I hope to see followers with even more interesting examples.

    Regards
    Mirza

  13. Siegfried Bolzon 07 May 2008 at 12:03 pm

    Hello Mirza,
    when i look at the last error message:

    D:\Documents and Settings\mirza.jahic\My Documents\NetBeansProjects\WebServiceApp\nbproject\jaxws-build.xml:24: wsimport failed

    it seems that something is wrong with the WSDL-file. Use the WSDL-file included in my example, don’t try to copy and paste it from this web page.

    Have you tried to download and run my example? download

  14. Mirzaon 07 May 2008 at 3:27 pm

    Hi,

    Yes, I tried to copy and paste from the website. I’ll try to use files from download link.

    Thanks
    Mirza

  15. Mirzaon 07 May 2008 at 4:33 pm

    Hi,

    Same problem even if I used you WSDLs.

    javac -d D:\Documents and Settings\mirza.jahic\My Documents\NetBeansProjects\WebServiceApp\build\generated\wsimport\binaries -classpath C:\Program Files\Java\jdk1.5.0_15\lib\tools.jar;C:\bea\weblogic92\server\lib\weblogic.jar;C:\bea\weblogic92\common\lib\apache_xbean.jar;C:\bea\weblogic92\server\lib\schema\weblogic-container-binding.jar;C:\bea\weblogic92\server\lib\schema\weblogic-domain-binding.jar;C:\bea\weblogic92\server\lib\schema\diagnostics-binding.jar;C:\bea\weblogic92\server\lib\schema\diagnostics-image-binding.jar;C:\bea\weblogic92\server\lib\wlcipher.jar;C:\bea\weblogic92\server\lib\jsafe.jar;C:\bea\weblogic92\server\lib\webservices.jar;C:\bea\weblogic92\server\lib\xmlx.jar;C:\bea\weblogic92\server\lib\ojdbc14.jar;C:\bea\weblogic92\server\lib\jconn2.jar;C:\bea\weblogic92\server\lib\jconn3.jar;C:\bea\weblogic92\server\lib\jConnect.jar;C:\bea\weblogic92\server\lib\cssjdkutils.jar;C:\bea\weblogic92\server\lib\cssapi.jar;C:\bea\weblogic92\server\lib\cssimpl.jar;C:\bea\weblogic92\server\lib\engapi.jar;C:\bea\weblogic92\server\lib\engimpl.jar;C:\bea\weblogic92\server\lib\EccpressoAsn1.jar;C:\bea\weblogic92\server\lib\EccpressoCore.jar;C:\bea\weblogic92\server\lib\EccpressoJcae.jar;C:\bea\weblogic92\server\lib\ant\ant.jar;C:\bea\weblogic92\server\lib\ant\ant-nodeps.jar;C:\bea\weblogic92\server\lib\ant\ant-antlr.jar;C:\bea\weblogic92\server\lib\ant\ant-jakarta-bcel.jar;C:\bea\weblogic92\server\lib\ant\ant-junit.jar;C:\bea\weblogic92\server\lib\ant\ant-vaj.jar;C:\bea\weblogic92\server\lib\ant\ant-apache-bsf.jar;C:\bea\weblogic92\server\lib\ant\ant-jakarta-log4j.jar;C:\bea\weblogic92\server\lib\ant\ant-launcher.jar;C:\bea\weblogic92\server\lib\ant\ant-weblogic.jar;C:\bea\weblogic92\server\lib\ant\ant-apache-resolver.jar;C:\bea\weblogic92\server\lib\ant\ant-jakarta-oro.jar;C:\bea\weblogic92\server\lib\ant\ant-netrexx.jar;C:\bea\weblogic92\server\lib\ant\ant-xalan1.jar;C:\bea\weblogic92\server\lib\ant\ant-commons-logging.jar;C:\bea\weblogic92\server\lib\ant\ant-jakarta-regexp.jar;C:\bea\weblogic92\server\lib\ant\ant-xalan2.jar;C:\bea\weblogic92\server\lib\ant\ant-commons-net.jar;C:\bea\weblogic92\server\lib\ant\ant-javamail.jar;C:\bea\weblogic92\server\lib\ant\ant-starteam.jar;C:\bea\weblogic92\server\lib\ant\ant-xslp.jar;C:\bea\weblogic92\server\lib\ant\ant-contrib-1.0b1.jar;C:\bea\weblogic92\server\lib\ant\ant-jdepend.jar;C:\bea\weblogic92\server\lib\ant\ant-stylebook.jar;C:\bea\weblogic92\server\lib\ant\ant-icontract.jar;C:\bea\weblogic92\server\lib\ant\ant-jmf.jar;C:\bea\weblogic92\server\lib\ant\ant-swing.jar;C:\bea\weblogic92\server\lib\ant\ant-jai.jar;C:\bea\weblogic92\server\lib\ant\ant-jsch.jar;C:\bea\weblogic92\server\lib\ant\ant-trax.jar;C:\bea\weblogic92\server\lib\ant\jakarta-oro-2.0.7.jar;C:\bea\weblogic92\server\lib\ant\commons-net-1.1.0.jar;C:\bea\weblogic92\server\lib\wlbase.jar;C:\bea\weblogic92\server\lib\wlutil.jar;C:\bea\weblogic92\server\lib\wlsqlserver.jar;C:\bea\weblogic92\server\lib\wldb2.jar;C:\bea\weblogic92\server\lib\wlsybase.jar;C:\bea\weblogic92\server\lib\wloracle.jar;C:\bea\weblogic92\server\lib\wlinformix.jar;C:\bea\weblogic92\server\lib\wlw-langx.jar;C:\bea\weblogic92\javelin\lib\javelinx.jar;C:\bea\weblogic92\javelin\lib\bcel-5.1.jar;C:\bea\weblogic92\common\lib\wlw-util.jar;C:\bea\weblogic92\server\lib\xbean.jar;C:\bea\weblogic92\server\lib\logkit\logkit.jar;C:\bea\weblogic92\common\lib\pdev.jar;C:\bea\weblogic92\common\lib;C:\bea\weblogic92\common\lib\3rdparty.jar;C:\bea\weblogic92\common\lib\plugin-wizard.jar;C:\bea\weblogic92\common\lib\comdev.jar;C:\bea\weblogic92\common\lib\wizard.jar;C:\bea\weblogic92\common\lib\plugin.jar;C:\bea\weblogic92\common\lib\oxy-cci.jar;C:\bea\weblogic92\common\lib\config.jar;C:\bea\weblogic92\common\lib\wlw-plaf.jar;C:\bea\weblogic92\common\lib\upgrade\common-plugin.jar;C:\bea\weblogic92\common\lib\jython.jar;C:\bea\weblogic92\server\lib\debugging.jar;C:\bea\weblogic92\server\lib\wlw-system.jar;C:\bea\weblogic92\server\lib\jcom.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\activation.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\FastInfoset.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\http.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\api\jaxb-api.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\jaxb-impl.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\jaxb-xjc.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\api\jaxws-api.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\jaxws-rt.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\saaj-impl.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\sjsxp.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\resolver.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\stax-ex.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\streambuffer.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\jaxws-tools.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\api\jsr173_api.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\api\jsr181-api.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\api\jsr250-api.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\api\saaj-api.jar -Xbootclasspath/p:C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\api\jaxws-api.jar;C:\Program Files\NetBeans 6.0.1\java1\modules\ext\jaxws21\api\jaxb-api.jar D:\Documents and Settings\mirza.jahic\My Documents\NetBeansProjects\WebServiceApp\build\generated\wsimport\service\eu\jdevelop\soapwebservices\CalculateValues.java D:\Documents and Settings\mirza.jahic\My Documents\NetBeansProjects\WebServiceApp\build\generated\wsimport\service\eu\jdevelop\soapwebservices\CalculateValuesResponse.java D:\Documents and Settings\mirza.jahic\My Documents\NetBeansProjects\WebServiceApp\build\generated\wsimport\service\eu\jdevelop\soapwebservices\ObjectFactory.java D:\Documents and Settings\mirza.jahic\My Documents\NetBeansProjects\WebServiceApp\build\generated\wsimport\service\eu\jdevelop\soapwebservices\SOAPService.java D:\Documents and Settings\mirza.jahic\My Documents\NetBeansProjects\WebServiceApp\build\generated\wsimport\service\eu\jdevelop\soapwebservices\SOAPWebServices.java D:\Documents and Settings\mirza.jahic\My Documents\NetBeansProjects\WebServiceApp\build\generated\wsimport\service\eu\jdevelop\soapwebservices\package-info.java
    D:\Documents and Settings\mirza.jahic\My Documents\NetBeansProjects\WebServiceApp\build\generated\wsimport\service\eu\jdevelop\soapwebservices\SOAPWebServices.java:35: cannot find symbol
    symbol : method partName()
    location: @interface javax.jws.WebParam
    @WebParam(name = “calculateValues”, targetNamespace = “soapwebservices.jdevelop.eu”, partName = “calculateValues”)
    D:\Documents and Settings\mirza.jahic\My Documents\NetBeansProjects\WebServiceApp\build\generated\wsimport\service\eu\jdevelop\soapwebservices\SOAPWebServices.java:33: cannot find symbol
    symbol : method partName()
    location: @interface javax.jws.WebResult
    @WebResult(name = “calculateValuesResponse”, targetNamespace = “soapwebservices.jdevelop.eu”, partName = “calculateValuesResponse”)
    2 errors
    compilation failed, errors should have been reported
    D:\Documents and Settings\mirza.jahic\My Documents\NetBeansProjects\WebServiceApp\nbproject\jaxws-build.xml:24: wsimport failed
    BUILD FAILED (total time: 1 minute 23 seconds)

    I guess , I have to take closer look to this problem.

    Regards
    Mirza

  16. Mirzaon 10 May 2008 at 8:26 pm

    Hi,

    It works now, I switched to Glass Fish 2 insted of weblogic. I tested it with SOAP UI and it looks ok.

    Do you have any sample code to call this service from the JSP instead?

    Thanks
    Mirza

  17. Siegfried Bolzon 11 May 2008 at 11:36 am

    No i don’t have a sample code. If you want to call this web service from a JSP-file, use scriptlets to invoke the corresponding classes.

  18. Mirzaon 14 May 2008 at 3:50 pm

    Thanks,

    I fixed it , it works fine.

    Mirza

  19. Siegfried Bolzon 14 May 2008 at 5:22 pm

    Great, what was the problem?

  20. Mirzaon 17 May 2008 at 6:19 pm

    Hi,

    It seems that my weblogic server was not properly configured for web services , this was making problems during the compilation of you classes, so I switched to Glass Fish and same code compiled.

    After testing it I chaged Index.jsp and added the code for calling your webservice from the jsp, it works fine. It would be great to see some example with security issues.

    JSP Page

    <%

    try {

    String value1 =request.getParameter(”value1″);
    String value2 =request.getParameter(”value2″);

    SOAPService service = new SOAPService();
    eu.jdevelop.soapwebservices.SOAPWebServices port = service.getWebServices();
    // TODO initialize WS operation arguments here
    CalculateValues calculateValues = new CalculateValues();

    calculateValues.setValue1(new BigDecimal(value1));
    calculateValues.setValue2(new BigDecimal(value2));

    // TODO process result here
    CalculateValuesResponse result = port.getCalculateValues(calculateValues);
    out.println(”Result = “+result.getResult()+”");

    } catch (Exception ex) {
    // TODO handle custom exceptions here
    }
    %>

  21. Debraj Suron 24 May 2008 at 9:49 am

    Hello Siegfried,

    Your post was very informative.

    I am trying to create this example on Netbeans 5.1 but when I am trying to create the blank web service I am getting an error that says

    “To create Web Services in this project, the java source level must be atleast jdk 1.5″

    I am already using jdk 1.5

    Do you have any idea what the problem could be?

    Thanks in Advance

    Debraj

  22. Siegfried Bolzon 24 May 2008 at 11:15 am

    Hello Debraj,
    open the Project Properties, go to the Category “Source” and choose JDK5 at “Source/Binary Format”. Hope this was the solution for you.

    Regards,
    Siegfried

  23. Jayon 06 Jun 2008 at 6:37 pm

    Hi,

    Pls ignore my question above….. dint see the last comment…. Thanks a lot

    Regards,
    Jay

  24. Jayon 06 Jun 2008 at 6:56 pm

    I have done Clean and build… but when I run… it says “Build of soapweservices (run) failed”

    I have TomCat5 installed.

  25. Siegfried Bolzon 06 Jun 2008 at 7:07 pm

    Please post an detailed error message from the NetBeans Output-console. Maybe there are some problems with Tomcat 5. Can you try Tomcat 6 to see if there is an error?

  26. Jayon 06 Jun 2008 at 9:56 pm

    Deployment error:
    Access to Tomcat server has not been authorized. Set the correct username and password with the “manager” role in the Tomcat customizer in the Server Manager.
    See the server log for details.
    at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:166)
    at org.netbeans.modules.j2ee.ant.Deploy.execute(Deploy.java:104)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    at sun.reflect.GeneratedMethodAccessor285.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:357)
    at org.apache.tools.ant.Target.performTasks(Target.java:385)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
    at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:277)
    at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:460)
    at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)
    Caused by: java.lang.IllegalStateException: Access to Tomcat server has not been authorized. Set the correct username and password with the “manager” role in the Tomcat customizer in the Server Manager.
    at org.netbeans.modules.tomcat5.TomcatManagerImpl.list(TomcatManagerImpl.java:389)
    at org.netbeans.modules.tomcat5.TomcatManager.modules(TomcatManager.java:623)
    at org.netbeans.modules.tomcat5.TomcatManager.getAvailableModules(TomcatManager.java:434)
    at org.netbeans.modules.j2ee.deployment.impl.TargetServer.getAvailableTMIDsMap(TargetServer.java:331)
    at org.netbeans.modules.j2ee.deployment.impl.TargetServer.checkUndeployForSharedReferences(TargetServer.java:287)
    at org.netbeans.modules.j2ee.deployment.impl.TargetServer.checkUndeployForSharedReferences(TargetServer.java:236)
    at org.netbeans.modules.j2ee.deployment.impl.TargetServer.checkUndeployForSharedReferences(TargetServer.java:233)
    at org.netbeans.modules.j2ee.deployment.impl.TargetServer.processLastTargetModules(TargetServer.java:355)
    at org.netbeans.modules.j2ee.deployment.impl.TargetServer.init(TargetServer.java:143)
    at org.netbeans.modules.j2ee.deployment.impl.TargetServer.deploy(TargetServer.java:479)
    at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:151)
    … 16 more
    Caused by: org.netbeans.modules.tomcat5.AuthorizationException
    at org.netbeans.modules.tomcat5.TomcatManagerImpl.list(TomcatManagerImpl.java:390)
    … 26 more
    BUILD FAILED (total time: 0 seconds)

    This is the error message. How do i set the authentication ?

  27. Siegfried Bolzon 06 Jun 2008 at 10:13 pm

    Open the file “tomcat-users.xml“, located in [APACHE-DIRECTORY]/conf and replace the content with this:

    <?xml version=’1.0′ encoding=’utf-8′?>
    <tomcat-users>
    <role rolename=”manager”/>
    <role rolename=”admin”/>
    <user username=”manager” password=”manager” roles=”manager,admin”/>
    </tomcat-users>

    After this open in your NetBeans the Server-Konfiguration (Tools->Server) and enter “manager” as the new password for the rolemanager“.

  28. Jayon 06 Jun 2008 at 11:19 pm

    Now while building i get the following error

    C:\Jayesh-Pls dont delete\Learn Java\NetBeam\SOAPWebServices\nbproject\jaxws-build.xml:11: taskdef class com.sun.tools.ws.ant.WsImport cannot be found
    BUILD FAILED (total time: 0 seconds)

  29. Siegfried Bolzon 06 Jun 2008 at 11:36 pm

    WsImport task is part of jaxws-tools.jar, which is part of JAX-WS 2.0 library in the IDE. You can also download it separately from https://jax-ws.dev.java.net/2.1.4/, or use the version from newest JDK 6 (just remove your old JDK and install the new one). Also note that if you’re using JAX-WS library you should also put JAXB library on the classpath.

    An other option is to copy all JAX-WS file to the directory JAVA_HOME/jre/lib/endorsed. Take a look at the section Possible Problem at the end of this blog.

    The easiest way is to install NetBeans 6.1 with jdk1.6.0_06 .

  30. Jayon 07 Jun 2008 at 12:10 am

    i have jdk1.6 installed. even tried copying endorsed folder to JRE/lib folder

  31. Siegfried Bolzon 07 Jun 2008 at 12:17 am

    Which jdk 6 version do you have installed? This bug was fixed with a version >1.6.3 . Also try Tomcat 6 or GlassFish 2.

  32. Jayon 07 Jun 2008 at 12:37 am

    I am using jdk1.6.0_06 and have added the JAX-WS library to the classpath. Let me try out with Tomcat 6.0 as well

    the funny part is that previously and it was building without any errors but did not run bcoz tomcat 5 was not configured correctly. now the build itself is giving me issues.

  33. Jayon 09 Jun 2008 at 12:31 pm

    I am able to build and run it but when it launchs in IE it gives me an error.

    HTTP Status 404 - /soapwebservices/

    ——————————————————————————–

    type Status report

    message /soapwebservices/

    description The requested resource (/soapwebservices/) is not available.

    ——————————————————————————–

    Sun-Java-System/Web-Services-Pack-1.4

  34. Siegfried Bolzon 09 Jun 2008 at 8:03 pm

    Have you removed the Context Path? click

  35. Jayon 09 Jun 2008 at 8:45 pm

    yes the context path is removed.
    I am trying to download ur code and deploy it on Glassfish

    Let me see what happens :)

  36. Jayon 09 Jun 2008 at 9:17 pm

    Still no go… following error comes up when I run it.

    Deployment error:
    The Sun Java System Application Server could not start.
    More information about the cause is in the Server log file.
    Possible reasons include:
    - IDE timeout: refresh the server node to see if it’s running now.
    - Port conflicts. (use netstat -a to detect possible port numbers already used by the operating system.)
    - Incorrect server configuration (domain.xml to be corrected manually)
    - Corrupted Deployed Applications preventing the server to start.(This can be seen in the server.log file. In this case, domain.xml needs to be modified).
    - Invalid installation location.
    See the server log for details.
    at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:166)
    at org.netbeans.modules.j2ee.ant.Deploy.execute(Deploy.java:104)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    at sun.reflect.GeneratedMethodAccessor47.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:357)
    at org.apache.tools.ant.Target.performTasks(Target.java:385)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
    at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:277)
    at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:460)
    at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)
    Caused by: org.netbeans.modules.j2ee.deployment.impl.ServerException: The Sun Java System Application Server could not start.
    More information about the cause is in the Server log file.
    Possible reasons include:
    - IDE timeout: refresh the server node to see if it’s running now.
    - Port conflicts. (use netstat -a to detect possible port numbers already used by the operating system.)
    - Incorrect server configuration (domain.xml to be corrected manually)
    - Corrupted Deployed Applications preventing the server to start.(This can be seen in the server.log file. In this case, domain.xml needs to be modified).
    - Invalid installation location.
    at org.netbeans.modules.j2ee.deployment.impl.ServerInstance._start(ServerInstance.java:1297)
    at org.netbeans.modules.j2ee.deployment.impl.ServerInstance.startTarget(ServerInstance.java:1251)
    at org.netbeans.modules.j2ee.deployment.impl.ServerInstance.startTarget(ServerInstance.java:1062)
    at org.netbeans.modules.j2ee.deployment.impl.ServerInstance.start(ServerInstance.java:939)
    at org.netbeans.modules.j2ee.deployment.impl.TargetServer.startTargets(TargetServer.java:428)
    at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:143)
    … 16 more
    BUILD FAILED (total time: 7 minutes 40 seconds)

  37. Siegfried Bolzon 09 Jun 2008 at 9:29 pm

    Corrupted Deployed Applications preventing the server to start.(This can be seen in the server.log file).
    Your problems are scary! Open server.log and search for an deployment error.

  38. Jayon 10 Jun 2008 at 8:33 pm

    Hurray atlast it worked….. :)

    I completely uninstalled Netbeans6.1 and reinstalled it. then did an update on Netbeans… downloaded all plugins… installed them ……. It works now.

    Thanks a lot Siegfried….. appreciate ur help……….

  39. Jayon 10 Jun 2008 at 9:15 pm

    Thanks Siegfried…. it works now.

    I reinstalled netbeans 6.1 and then updated the plugins and it works now

  40. Siegfried Bolzon 10 Jun 2008 at 9:16 pm

    Great job! So you can now enjoy all my tutorials. Have a lot of fun!

  41. Alexon 11 Jun 2008 at 6:21 am

    Hi Siegfried,

    When I am about to change the url-pattern, I realized that the file “sun-jaxws.xml” is not there, and the content of “web.xml” is very short compare to what you have. Any reason why? Sorry I am new in this.

    Regards,
    Alex

  42. Siegfried Bolzon 11 Jun 2008 at 5:25 pm

    Hi Alex,
    have you followed all steps in this blog? NetBeans creates automatically both files for you. Perhaps, it is an NetBeans error. Try again all steps with NetBeans 6.1 .

    Regards,
    Siegfried

  43. Alexon 11 Jun 2008 at 7:12 pm

    Hi Siegfried,

    Yes, I followed every single step, and I am using NetBeans 6.1 currently. Still the same issue persists.

    Regards,
    Alex

  44. Alexon 12 Jun 2008 at 12:56 am

    Hi Siegfried,

    I managed to get it works, somehow, but I am facing another issue. Basically, this is how my XML Schema looks like for output;

    I managed to get the value from the “Response” and “ResponseDetail” elements but not to set the value.

    This is how I set the value;

    response.getDataResponse.get(0).setResponse(”100 - Failed”);
    response.getDataResponse.get(0).setResponseDetail(”Structure incorrect”);

    But I encountered “java.lang.IndexOutOfBoundExceptions: Index: 0, Size: 0

    Can you give me some tips?

    Regards,
    Alex

  45. Siegfried Bolzon 12 Jun 2008 at 8:23 am

    Hello Alex,

    could be a mismatch in the XML schema. Please post the created Java Response-File.

    Regards,
    Siegfried

  46. Alexon 12 Jun 2008 at 11:33 pm

    Hi Siegfried,

    I am not sure if you got my email, anyway, below is the Java Response-File.

    package com.onsemi.middleware.ws;

    import java.util.ArrayList;
    import java.util.List;
    import javax.xml.bind.annotation.XmlAccessType;
    import javax.xml.bind.annotation.XmlAccessorType;
    import javax.xml.bind.annotation.XmlElement;
    import javax.xml.bind.annotation.XmlRootElement;
    import javax.xml.bind.annotation.XmlType;

    /**
    * Java class for anonymous complex type.
    *
    * The following schema fragment specifies the expected content contained within this class.
    *
    *
    * <complexType>
    * <complexContent>
    * <restriction base=”{http://www.w3.org/2001/XMLSchema}anyType”>
    * <sequence>
    * <element name=”UnitOfWork” maxOccurs=”unbounded” minOccurs=”0″>
    * <complexType>
    * <complexContent>
    * <restriction base=”{http://www.w3.org/2001/XMLSchema}anyType”>
    * <sequence>
    * <element name=”ServiceResponse” type=”{http://www.w3.org/2001/XMLSchema}string”/>
    * <element name=”ServiceResponseDetail” type=”{http://www.w3.org/2001/XMLSchema}string”/>
    * </sequence>
    * </restriction>
    * </complexContent>
    * </complexType>
    * </element>
    * </sequence>
    * </restriction>
    * </complexContent>
    * </complexType>
    *
    *
    *
    */
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = “”, propOrder = {
    “unitOfWork”
    })
    @XmlRootElement(name = “centralDataResponse”)
    public class CentralDataResponse {

    @XmlElement(name = “UnitOfWork”)
    protected List unitOfWork;

    /**
    * Gets the value of the unitOfWork property.
    *
    *
    * This accessor method returns a reference to the live list,
    * not a snapshot. Therefore any modification you make to the
    * returned list will be present inside the JAXB object.
    * This is why there is not a set method for the unitOfWork property.
    *
    *
    * For example, to add a new item, do as follows:
    *
    * getUnitOfWork().add(newItem);
    *
    *
    *
    *
    * Objects of the following type(s) are allowed in the list
    * {@link CentralDataResponse.UnitOfWork }
    *
    *
    */
    public List getUnitOfWork() {
    if (unitOfWork == null) {
    unitOfWork = new ArrayList();
    }
    return this.unitOfWork;
    }

    /**
    * Java class for anonymous complex type.
    *
    * The following schema fragment specifies the expected content contained within this class.
    *
    *
    * <complexType>
    * <complexContent>
    * <restriction base=”{http://www.w3.org/2001/XMLSchema}anyType”>
    * <sequence>
    * <element name=”ServiceResponse” type=”{http://www.w3.org/2001/XMLSchema}string”/>
    * <element name=”ServiceResponseDetail” type=”{http://www.w3.org/2001/XMLSchema}string”/>
    * </sequence>
    * </restriction>
    * </complexContent>
    * </complexType>
    *
    *
    *
    */
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = “”, propOrder = {
    “serviceResponse”,
    “serviceResponseDetail”
    })
    public static class UnitOfWork {

    @XmlElement(name = “ServiceResponse”, required = true)
    protected String serviceResponse;
    @XmlElement(name = “ServiceResponseDetail”, required = true)
    protected String serviceResponseDetail;

    /**
    * Gets the value of the serviceResponse property.
    *
    * @return
    * possible object is
    * {@link String }
    *
    */
    public String getServiceResponse() {
    return serviceResponse;
    }

    /**
    * Sets the value of the serviceResponse property.
    *
    * @param value
    * allowed object is
    * {@link String }
    *
    */
    public void setServiceResponse(String value) {
    this.serviceResponse = value;
    }

    /**
    * Gets the value of the serviceResponseDetail property.
    *
    * @return
    * possible object is
    * {@link String }
    *
    */
    public String getServiceResponseDetail() {
    return serviceResponseDetail;
    }

    /**
    * Sets the value of the serviceResponseDetail property.
    *
    * @param value
    * allowed object is
    * {@link String }
    *
    */
    public void setServiceResponseDetail(String value) {
    this.serviceResponseDetail = value;
    }

    }

    }

    Regards,
    Alex

  47. Siegfried Bolzon 13 Jun 2008 at 9:18 pm

    Hello Alex,
    i think i have solved your problem:

    package testapp;

    import com.onsemi.middleware.ws.CentralDataResponse;
    import com.onsemi.middleware.ws.CentralDataResponse.UnitOfWork;

    /**
    *
    * @author Siegfried Bolz
    */
    public class Main {

    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {

    UnitOfWork unit = new UnitOfWork();
    unit.setServiceResponse(”100 - Failed”);
    unit.setServiceResponseDetail(”Structure incorrect”);

    CentralDataResponse response = new CentralDataResponse();
    response.getUnitOfWork().add(unit);

    System.out.println(response.getUnitOfWork().get(0).getServiceResponse());

    }
    }

  48. sandhyaon 09 Jul 2008 at 2:44 pm

    can you suggest me how to log all the events occuring in a web service which is created.

  49. Siegfried Bolzon 09 Jul 2008 at 7:10 pm

    You can do this in the method “public CalculateValuesResponse getCalculateValues(CalculateValues calculateValues)“. For more detailed information take a look at my other blog How to modify JAX-WS SOAP-Messages. You can add your logging in the class ServerSOAPHandler.

  50. prethamon 11 Aug 2008 at 3:15 pm

    sir i hav poblem in running weblogic 10 in netbeans6.1…..can any any one tell me how to run ..plz tell me

  51. Damodaron 02 Sep 2008 at 6:22 am

    Sir, Thanks for your nice blog. I was trying to run the sample in Netbeans 6.1 with Weblogic 10; but getting doployment error. Can you please help me?

    Regards,
    Damodar…

  52. Dreamcatcheron 06 Nov 2008 at 1:36 pm

    Thanks Mr. Siegfried for this worthful article. But i have a problem now. I create the webservice same as following your steps but i when the last step comes where you clicks at run and my application get deployed over server nothing opens again http://localhost:8084. I have tried this address both on Opera and IExplorer but nothing returns. Also i changed the port number to 8080 but invain. Infact when i click run a web page opens over which i got the message that requested resource is not available. So please help me i m in great need. I will appreciate if you will solve my problem.
    Thanks waiting 4 worthful reply..

  53. Siegfried Bolzon 07 Nov 2008 at 8:25 pm

    Hello Dreamcatcher,
    have you tried the full URL as displayed in this picture: click ? Don’t forget to add the context “soapwebservices” to the URL.

  54. usmanon 22 Nov 2008 at 9:21 am

    hi i got this error while running this application can u plz help me to solve this

    Using CATALINA_BASE: C:\Tomcat_6_0_14
    Using CATALINA_HOME: C:\Tomcat_6_0_14
    Using CATALINA_TMPDIR: C:\Tomcat_6_0_14\temp
    Using JRE_HOME: C:\Program Files\Java\jdk1.5.0_06
    java.lang.NoClassDefFoundError: Files\Java\jdk1/5/0_06\lib\tools/jar;C:\Tomcat_6_0_14\bin\bootstrap/jar -Dcatalina/base=C:\Tomcat_6_0_14 -Dcatalina/home=C:\Tomcat_6_0_14 -Djava/io/tmpdir=C:\Tomcat_6_0_14\temp org/apache/catalina/startup/Bootstrap start
    Exception in thread “main”

    Starting of Tomcat failed.
    Deployment error:
    Starting of Tomcat failed.
    See the server log for details.
    at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:163)
    at org.netbeans.modules.j2ee.ant.Deploy.execute(Deploy.java:104)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    at sun.reflect.GeneratedMethodAccessor374.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:357)
    at org.apache.tools.ant.Target.performTasks(Target.java:385)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
    at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:277)
    at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:460)
    at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)
    Caused by: org.netbeans.modules.j2ee.deployment.impl.ServerException: Starting of Tomcat failed.
    at org.netbeans.modules.j2ee.deployment.impl.ServerInstance._start(ServerInstance.java:1270)
    at org.netbeans.modules.j2ee.deployment.impl.ServerInstance.startTarget(ServerInstance.java:1224)
    at org.netbeans.modules.j2ee.deployment.impl.ServerInstance.startTarget(ServerInstance.java:1035)
    at org.netbeans.modules.j2ee.deployment.impl.ServerInstance.start(ServerInstance.java:912)
    at org.netbeans.modules.j2ee.deployment.impl.TargetServer.startTargets(TargetServer.java:417)
    at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:140)
    … 16 more
    BUILD FAILED (total time: 1 second)

  55. usmanon 29 Nov 2008 at 5:39 am

    Hi Mr. Siegfried

    The above error came at deployment time only i m using tomcat 6.14 and jdk 1.5 it works fine in glass fish.i got a error in tomcat only.

  56. Roger Leeon 05 Dec 2008 at 11:10 am

    Been through the tutorial four times, create a new project each time, using NetBeans 6.5.

    It doesn’t create the sun-jaxws.xml file.

  57. TeodorMon 24 Jul 2009 at 10:17 am

    Hi there I have downloaded the free fersion of soapui but I cannot find from where to install it. There is no installation file that i can find. It should be build or what? Any ideas?

  58. Eustasson 09 Nov 2009 at 7:49 am

    Hi
    thanks lot for the article, it helps lot,
    but if I use JBoss server without using Apache tomcat it is bit difficult. Can u tell me where I have to do the below step with JBOSS.

    “It’s now time to change the url-pattern. Open the file “sun-jaxws.xml” and exchange the url-pattern with “/soapwebservices“.”

    In JBOSS there wasn’t sun-jaxws.xml file (I searched, but couldnt find it).

    Please help me
    Thanks lot,

  59. Nichten der Frau Oberston 07 Dec 2009 at 9:09 am

    It worked like a charm for me, I am happy to use it, Thanks Siegfried Bolz , for this nice thing, Your article was no less than a movie download that we get as tutorials.

  60. sunRiseon 24 Jan 2010 at 3:36 pm

    hi..
    actually i have a big problem, i need to apply SOAP in my final year project for my final semester..the problem is to send the form through SOAP. but i doesn’t know how to start it..could you give some help to me..thaks

  61. dalyon 10 May 2010 at 11:48 am

    hello there !!!
    i teste this class but i’ve got this probleme. :s

    12:39:27,427 ERROR [STDERR] javax.xml.soap.SOAPException: SOAPEnvelope already has a header element
    12:39:27,427 ERROR [STDERR] at org.jboss.ws.core.soap.SOAPEnvelopeImpl.addHeader(SOAPEnvelopeImpl.java:118)
    12:39:27,427 ERROR [STDERR] at com.tritux.webservices.ServerSOAPHandler.handleMessage(ServerSOAPHandler.java:117)
    12:39:27,427 ERROR [STDERR] at com.tritux.webservices.ServerSOAPHandler.handleMessage(ServerSOAPHandler.java:1)
    12:39:27,427 ERROR [STDERR] at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.handleMessage(HandlerChainExecutor.java:305)
    12:39:27,427 ERROR [STDERR] at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.handleMessage(HandlerChainExecutor.java:142)
    12:39:27,427 ERROR [STDERR] at org.jboss.ws.core.jaxws.handler.HandlerDelegateJAXWS.callResponseHandlerChain(HandlerDelegateJAXWS.java:105)
    12:39:27,427 ERROR [STDERR] at org.jboss.ws.core.server.ServiceEndpointInvoker.callResponseHandlerChain(ServiceEndpointInvoker.java:129)
    12:39:27,427 ERROR [STDERR] at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:269)
    12:39:27,428 ERROR [STDERR] at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:468)
    12:39:27,428 ERROR [STDERR] at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:293)
    12:39:27,428 ERROR [STDERR] at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:203)
    12:39:27,428 ERROR [STDERR] at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:129)
    12:39:27,428 ERROR [STDERR] at org.jboss.wsf.common.servlet.AbstractEndpointServlet.service(AbstractEndpointServlet.java:85)
    12:39:27,428 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    12:39:27,428 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    12:39:27,428 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    12:39:27,428 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    12:39:27,428 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    12:39:27,428 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    12:39:27,428 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
    12:39:27,428 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    12:39:27,428 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
    12:39:27,428 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
    12:39:27,428 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
    12:39:27,428 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
    12:39:27,428 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    12:39:27,428 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    12:39:27,428 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
    12:39:27,428 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    12:39:27,428 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
    12:39:27,428 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
    12:39:27,429 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
    12:39:27,429 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    12:39:27,429 ERROR [STDERR] at java.lang.Thread.run(Thread.java:619)
    12:44:22,254 INFO [ServletContextListener] Welcome to Seam 2.1.0.SP1
    12:44:27,899 WARN [Component] Component class should be serializable: org.jboss.seam.ui.facelet.mockHttpSession
    12:44:27,933 WARN [Component] Component class should be serializable: sessionInfoAction
    12:44:27,959 WARN [PersistentPermissionResolver] no permission store available - please install a PermissionStore with the name ‘org.jboss.seam.security.jpaPermissionStore’ if persistent permissions are required.
    12:44:45,097 INFO [BootstrapAction] Initializing Administration Console v1.3.2.GA…
    12:44:49,055 WARN [SystemInfoFactory] System info API not accessible on this platform (native shared library not found in java.library.path).
    12:44:49,386 INFO [PluginContainerResourceManager] Discovering Resources…
    12:44:49,565 WARN [JMXDiscoveryComponent] Unable to complete base jmx server discovery (enable DEBUG for stack): java.lang.UnsupportedOperationException: No native library available - Cannot get the process table information without native support
    12:45:15,934 INFO [Version] Hibernate Validator 3.1.0.GA
    12:45:15,961 INFO [Version] Hibernate Commons Annotations 3.1.0.GA

  62. laxshon 08 Jul 2010 at 4:41 am

    Hi,

    Im new to Web Services. I have an application in which the client will send a request to get some information about the customer through web services.
    How can the user access my web service? Do i need to create a web page which will in turn cal my web service or directly can they access my web service?

    Thanks for the reply.

Trackback URI | Comments RSS

Leave a Reply

*
To prove that you're not a bot, enter this code
Anti-Spam Image

Note: To submit your comment you have to preview it at first!