Solved

Java creating class giving error

Posted on 2010-09-12
12
762 Views
Last Modified: 2013-12-15
Why this error occurs the package is already there
error.png
0
Comment
Question by:3XLcom
  • 6
  • 4
  • 2
12 Comments
 
LVL 20

Assisted Solution

by:a_b
a_b earned 400 total points
ID: 33656851
Pnum is the package name. You need Pnum to be a class for the code to compile.
0
 
LVL 20

Accepted Solution

by:
a_b earned 400 total points
ID: 33656855
Packages have classes inside them which you can instantiate; you cannot instantiate a package.
0
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 33656871
Agree.  I got my Netbeans reinstalled and generated the web service code just fine and is the package containing all the generated code for the service.  If you expand that you will see the EVDServis.java file and associated files.  Just make sure to go into that file and change the URL per instructions.
0
 

Author Comment

by:3XLcom
ID: 33656905
This is the final i think and it will work after i solv this last step :

code giving error for here :


 JAXBElement<PmumService.LoginMessage> el = new JAXBElement<PmumService.LoginMessage>(sv);
/*

 * To change this template, choose Tools | Templates

 * and open the template in the editor.

 */



package ginageldi;

/**

 *

 * @author Cahit

 */

import PmumService.StringValue;

import javax.xml.bind.JAXBElement;

import javax.xml.namespace.QName;





public class Main {

    QName qName = new QName("http://tempuri.org", "Test");



public javax.xml.bind.JAXBElement<PmumService.LoginMessage> Mesaj() {

        PmumService.LoginMessage sv = new PmumService.LoginMessage() ;

        sv.setPassword(getPass());

        sv.setUserName(getUserName());

        JAXBElement<PmumService.LoginMessage> el = new JAXBElement<PmumService.LoginMessage>(sv);

        return el;

   }

    public JAXBElement<PmumService.StringValue> getUserName() {

        StringValue sv = new StringValue() ;

        sv.setV("example");

        JAXBElement<StringValue> el = new JAXBElement<StringValue>(qName, StringValue.class, null, sv);

        return el;

   }

    public JAXBElement<PmumService.StringValue> getPass() {

        StringValue sv = new StringValue() ;

        sv.setV("example");

        JAXBElement<StringValue> el = new JAXBElement<StringValue>(qName, StringValue.class, null, sv);

        return el;

   }



    public static void main(String[] args) {

            PmumService.Login cr = new PmumService.Login();

            cr.setLoginMessage(  new Main().Mesaj());

            try

            {

                javax.xml.bind.JAXBContext jaxbCtx = javax.xml.bind.JAXBContext.newInstance(cr.getClass().getPackage().getName());

                javax.xml.bind.Marshaller marshaller = jaxbCtx.createMarshaller();

                marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_ENCODING, "UTF-8"); //NOI18N

                marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);

                marshaller.marshal(cr, System.out);

            } 

            catch (javax.xml.bind.JAXBException ex)

            {

                // XXXTODO Handle exception

                java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.SEVERE, null, ex); //NOI18N

            }

    }



}













And This is PmumLoginMessage Class :









//

// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.2-147 

// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 

// Any modifications to this file will be lost upon recompilation of the source schema. 

// Generated on: 2010.09.12 at 05:30:57 PM EEST 

//





package PmumService;



import javax.xml.bind.JAXBElement;

import javax.xml.bind.annotation.XmlAccessType;

import javax.xml.bind.annotation.XmlAccessorType;

import javax.xml.bind.annotation.XmlElementRef;

import javax.xml.bind.annotation.XmlType;





/**

 * <p>Java class for LoginMessage complex type.

 * 

 * <p>The following schema fragment specifies the expected content contained within this class.

 * 

 * <pre>

 * &lt;complexType name="LoginMessage">

 *   &lt;complexContent>

 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">

 *       &lt;sequence>

 *         &lt;element name="Password" type="{http://ws.dgpys.deloitte.com}StringValue" minOccurs="0"/>

 *         &lt;element name="UserName" type="{http://ws.dgpys.deloitte.com}StringValue" minOccurs="0"/>

 *       &lt;/sequence>

 *     &lt;/restriction>

 *   &lt;/complexContent>

 * &lt;/complexType>

 * </pre>

 * 

 * 

 */

@XmlAccessorType(XmlAccessType.FIELD)

@XmlType(name = "LoginMessage", propOrder = {

    "password",

    "userName"

})

public class LoginMessage {



    @XmlElementRef(name = "Password", type = JAXBElement.class, required = false)

    protected JAXBElement<StringValue> password;

    @XmlElementRef(name = "UserName", type = JAXBElement.class, required = false)

    protected JAXBElement<StringValue> userName;



    /**

     * Gets the value of the password property.

     * 

     * @return

     *     possible object is

     *     {@link JAXBElement }{@code <}{@link StringValue }{@code >}

     *     

     */

    public JAXBElement<StringValue> getPassword() {

        return password;

    }



    /**

     * Sets the value of the password property.

     * 

     * @param value

     *     allowed object is

     *     {@link JAXBElement }{@code <}{@link StringValue }{@code >}

     *     

     */

    public void setPassword(JAXBElement<StringValue> value) {

        this.password = ((JAXBElement<StringValue> ) value);

    }



    /**

     * Gets the value of the userName property.

     * 

     * @return

     *     possible object is

     *     {@link JAXBElement }{@code <}{@link StringValue }{@code >}

     *     

     */

    public JAXBElement<StringValue> getUserName() {

        return userName;

    }



    /**

     * Sets the value of the userName property.

     * 

     * @param value

     *     allowed object is

     *     {@link JAXBElement }{@code <}{@link StringValue }{@code >}

     *     

     */

    public void setUserName(JAXBElement<StringValue> value) {

        this.userName = ((JAXBElement<StringValue> ) value);

    }



}

Open in new window

0
 
LVL 59

Assisted Solution

by:Kevin Cross
Kevin Cross earned 100 total points
ID: 33656953

JAXBElement<LoginMessage> el = new JAXBElement<LoginMessage>(qName, LoginMessage.class, sv);

        

Open in new window

0
 

Author Comment

by:3XLcom
ID: 33656983
Wonderfull mwvisa :)

This is what i see on the output :

run:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:login xmlns:ns2="http://ws.dgpys.deloitte.com">
    <ns3:Test xmlns:ns3="http://tempuri.org">
        <ns3:Test v="example"/>
        <ns3:Test v="example"/>
    </ns3:Test>
</ns2:login>
BUILD SUCCESSFUL (total time: 1 second)

So how could i write the answer of service this is the end :)
I see that i send the required info. now i need to get only the answer :)
  public static void main(String[] args) {

            PmumService.Login cr = new PmumService.Login();

            cr.setLoginMessage(  new Main().Mesaj());

            try

            {

                javax.xml.bind.JAXBContext jaxbCtx = javax.xml.bind.JAXBContext.newInstance(cr.getClass().getPackage().getName());

                javax.xml.bind.Marshaller marshaller = jaxbCtx.createMarshaller();

                marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_ENCODING, "UTF-8"); //NOI18N

                marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);

                marshaller.marshal(cr, System.out);

            } 

            catch (javax.xml.bind.JAXBException ex)

            {

                // XXXTODO Handle exception

                java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.SEVERE, null, ex); //NOI18N

            }

    }

Open in new window

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 59

Expert Comment

by:Kevin Cross
ID: 33657081
Not sure which of the different operations you need to do to accomplish what you are being asked to do.  I would look at the information provided by the service provider on the typical operations used.  Here is a tutorial on creating the WS client as you have completed the introduction which is getting the JAXB elements in place and tested.

http://netbeans.org/kb/docs/websvc/client.html#creatingtheclient
0
 

Author Comment

by:3XLcom
ID: 33657102
I am just trying to execute login method.
0
 

Author Comment

by:3XLcom
ID: 33657137
I tryed this but not worked
         javax.xml.ws.AsyncHandler<PmumService.Login> = new javax.xml.ws.AsyncHandler<PmumService.Login>() { 

             public void handleResponse(javax.xml.ws.Response<PmumService.Login> response) {

                 try {

                     System.out.println("Result = "+ response.get());

                 } catch(Exception ex) {

                 }            

             }

         };

Open in new window

0
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 33657156
This is probably going to stray far from the question as stated here, so I would suggest awarding answer to a_b for pointing out you were using the package name as a class incorrectly which answers the question as stated and I will respond to login() method in your previous question which deals with that topic but using your new code since it would appear that is not completely answered.
0
 

Author Closing Comment

by:3XLcom
ID: 33657178
Please Check this out for final step thanks :

http://www.experts-exchange.com/newQuestionWizard.jsp
0
 

Author Comment

by:3XLcom
ID: 33657180
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupSum5 challenge 5 68
Systems talking to each other 5 124
Groovy:unable to resolve class error 2 66
netstat -ano | find "8000" and taskkill /f /pid 2984 3 30
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now