Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Web Service Schema input parameter is null

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Web Service Schema input parameter is null

    Total beginner and need some help ?

    I've created a web service that basically parses the contents of an object and then marshalls it to an xml file.
    The input parameter of my web service has been created via an xml schema.

    Calling the web service (via soap message) does not populate the input parameter object - it's just null.

    I am using netbeans / glassfish but cannot see any errors.

    Can anyone point me in the right direction ??


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Web Service Schema input parameter is null

    Could you provide me with some code and explain what it is you are trying to do again because I'm not sure I understand where or what is wrong.

    // Json

  3. #3
    Junior Member
    Join Date
    Jan 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Web Service Schema input parameter is null

    I'm probably describing it all wrong again but here goes.....

    Basically I've created a web service that in a nutshell is supposed to save an xml file with some order details.
    I created an order schema, then created a wsdl from which I then created my web service.
    I then deployed onto glassfish server.


    package webServicePackage;
    import jackelwebservices.test.weborderschema.OrderType;
    import jackelwebservices.test.webservice.WebServicePortType;
    import java.io.FileOutputStream;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import javax.jws.HandlerChain;
    import javax.jws.WebService;
    import javax.xml.bind.JAXBContext;
    import javax.xml.bind.Marshaller;
     
    @WebService(serviceName = "webServiceService",
                portName = "webServicePort",
                endpointInterface = "jackelwebservices.test.webservice.WebServicePortType",
                targetNamespace = "http://test.jackelwebservices/webService.wsdl",
                wsdlLocation = "WEB-INF/wsdl/webService/webService.wsdl")
     
    @HandlerChain(file = "webService_handler.xml")
     
    public class webService implements WebServicePortType {
     
        public java.lang.String getWebOrder(jackelwebservices.test.weborderschema.OrderType inOrder) {
            // Initialisations;
            String rtnStatus = "OK";
            String xmlFile = null;
            String apDate = null;
     
            // Get current Date;
            DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss");
            Date curDate = new Date();
            apDate = dateFormat.format(curDate);
     
     
            // Set file name;
            if (inOrder.getOrderRef() == null) {
                xmlFile = "E:\\FTP\\Website\\Orders\\Order_" + apDate.trim() + ".xml";
            } else {
                xmlFile = "E:\\FTP\\Website\\Orders\\Order_" + inOrder.getOrderRef() + ".xml";
            }
     
            // Marshall object to xml file;
            try {
     
                // Create the JAXB context passing in the object to marshall to XML;
                final JAXBContext context = JAXBContext.newInstance(OrderType.class);
     
                // Create the marshaller to transform object to XML;
                final Marshaller marshaller = context.createMarshaller();
     
                // Marshal the object and write the XML to the string writer;
                marshaller.marshal(inOrder, new FileOutputStream(xmlFile));
     
     
            } catch (Exception e) {
                // Handle exception if required;
            }
            // Return status;
            return rtnStatus;
     
        }
     
    }

    When calling the web service with the following SOAP message, the input parameter is null.
    I assumed the SOAP details would be automatically parsed to the imput parameter, have a missed something ?

    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><ns2:getWebOrder xmlns:ns2="http://test.jackelwebservices/webService.wsdl"/><inOrder><Territory>UK</Territory><Order_Ref>d12345</Order_Ref><Payment_Ref>p12345</Payment_Ref><Cust_Name>Vicky Wilkinson</Cust_Name><Cust_Email>vwilkinson@jackel.co.uk</Cust_Email><Address_1>Address LIne 1</Address_1><Address_2>Address LIne 2</Address_2><Address_3>Address Line 3</Address_3><Address_4>Address Line 4</Address_4><Country>United Kingdom</Country><Postcode>NE12 7RH</Postcode><Goods_Price>1.0</Goods_Price><Ship_Price>1.0</Ship_Price><Total_Tax>0.5</Total_Tax><Currency>GBP</Currency><Order_Date>2009-12-14 12.02.53</Order_Date><Desp_Type>Royal Mail</Desp_Type><Items><Item><itemCode>42212010</itemCode><orderQty>10.0</orderQty><orgPrice>1.0</orgPrice><discount/><discCode/><warehouse>W3</warehouse><total>1.5</total></Item><Item><itemCode>42212410</itemCode><orderQty>5.0</orderQty><orgPrice>1.5</orgPrice><discount/><discCode/><warehouse>W3</warehouse><total>2.5</total></Item></Items></inOrder></SOAP-ENV:Body></SOAP-ENV:Envelope>

  4. #4
    Junior Member
    Join Date
    Jan 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Web Service Schema input parameter is null

    I managed to sort this problem (with the help of an expert !).
    Basically I had to create a new web service without the simple interface bits on.
    Although the web service compiled and deployed correctly it would not pick up any of the details being sent.

    Simply, creating the web service without the interface bits has worked like a charm. I was told that it may have been confusions with the webapp and debugger (being a newbie I don't really understand what that means but I'm sure the penny will drop someday).

    I have a working web service, a very small step in the world of java for me.

  5. #5
    Member
    Join Date
    Feb 2010
    Location
    Dehradun, India
    Posts
    37
    Thanks
    1
    Thanked 7 Times in 6 Posts

    Default Re: Web Service Schema input parameter is null

    Hi..

    What is this jackelwebservices??

  6. #6
    Junior Member
    Join Date
    Feb 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Web Service Schema input parameter is null

    Hi, Wilky. I think I'm more of a newbie than you are because I didn't understand what you meant when you wrote "Basically I had to create a new web service without the simple interface bits on. " Could you please post the code that worked for you?

    Thanks. Carol.

Similar Threads

  1. [SOLVED] Web Service from WSDL
    By wilky in forum Java Theory & Questions
    Replies: 3
    Last Post: January 25th, 2010, 10:45 AM
  2. How do you pass an Array as a Parameter?
    By Arius in forum Java Theory & Questions
    Replies: 1
    Last Post: January 23rd, 2010, 09:36 PM
  3. simple login web service
    By mr_aliagha in forum JavaServer Pages: JSP & JSTL
    Replies: 3
    Last Post: January 5th, 2010, 03:49 PM
  4. Passing objects as a constructor parameter
    By derky in forum Object Oriented Programming
    Replies: 2
    Last Post: October 27th, 2009, 04:31 AM
  5. Free java hosting service providers
    By servlet in forum Java Servlet
    Replies: 1
    Last Post: May 14th, 2009, 07:28 AM