Hi,

I have a simple jaxws-war test that would display the GreetMeResponse when the jsp client tries to invoke the Greeme method.

This test has been working for a while but it stopped working when I tried it today. Here's the exception:

javax.xml.ws.WebServiceException: javax.xml.bind.UnmarshalException
 - with linked exception:
[javax.xml.bind.UnmarshalException: unexpected element (uri:"http://apache.org/g reeter_control", local:"greetMeResponse"). Expected elements are <{http://apache
.org/greeter_control/types}faultDetail>,<{http://apache.org/greeter_control/type
s}greetMe>,<{http://apache.org/greeter_control/types}greetMeOneWay>,<{http://apa
che.org/greeter_control/types}greetMeResponse>,<{http://apache.org/greeter_contr
ol/types}pingMe>,<{http://apache.org/greeter_control/types}pingMeResponse>,<{htt
p://apache.org/greeter_control/types}sayHi>,<{http://apache.org/greeter_control/
types}sayHiResponse>]
at org.apache.axis2.jaxws.ExceptionFactory.createWebServiceException(Exc
eptionFactory.java:172)
Listening for transport dt_socket at address: 8008
at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(Excep
tionFactory.java:67)
at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(Excep
tionFactory.java:125)
at org.apache.axis2.jaxws.message.databinding.impl.JAXBBlockImpl.unmarsh
alByElement(JAXBBlockImpl.java:287)
at org.apache.axis2.jaxws.message.databinding.impl.JAXBBlockImpl._getBOF
romReader(JAXBBlockImpl.java:116)
at org.apache.axis2.jaxws.message.impl.BlockImpl.getBusinessObject(Block
Impl.java:142)
at org.apache.axis2.jaxws.message.impl.XMLSpineImpl._getBlockFromOMEleme
nt(XMLSpineImpl.java:494)
at org.apache.axis2.jaxws.message.impl.XMLSpineImpl.getBodyBlock(XMLSpin
eImpl.java:319)
at org.apache.axis2.jaxws.message.impl.XMLPartBase.getBodyBlock(XMLPartB
ase.java:505)
at org.apache.axis2.jaxws.message.impl.MessageImpl.getBodyBlock(MessageI
mpl.java:471)
at org.apache.axis2.jaxws.marshaller.impl.alt.DocLitWrappedMethodMarshal
ler.demarshalResponse(DocLitWrappedMethodMarshaller.java:106)
at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.createResponse(
JAXWSProxyHandler.java:356)
at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod
(JAXWSProxyHandler.java:274)
at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invoke(JAXWSPro
xyHandler.java:136)
        at $Proxy28.greetMe(Unknown Source)
at org.apache.jsp.JAXWSClient_jsp._jspService(JAXWSClient_jsp.java:74) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:384)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
20)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:228)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:175)
at org.apache.geronimo.tomcat.valve.DefaultSubjectValve.invoke(DefaultSu
bjectValve.java:56)
at org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.
invoke(GeronimoStandardContext.java:324)
at org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke(Gero
nimoBeforeAfterValve.java:47)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:
543)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:216)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ss(Http11Protocol.java:634)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:44
5)
        at java.lang.Thread.run(Thread.java:595)

Here's my .wsdl, SEI, SEIC and client jsp file:

Thanks, Lin

/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.greeter_control;

import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;


@WebService(name = "Greeter", targetNamespace = 
"http://apache.org/greeter_control";)
public interface Greeter {


    /**
     * 
     * @return
     *     returns java.lang.String
     */
    @WebMethod
    @WebResult(name = "responseType", targetNamespace = 
"http://apache.org/greeter_control/types";)
    @RequestWrapper(localName = "sayHi", targetNamespace = 
"http://apache.org/greeter_control/types";, className = 
"org.apache.greeter_control.types.SayHi")
    @ResponseWrapper(localName = "sayHiResponse", targetNamespace = 
"http://apache.org/greeter_control/types";, className = 
"org.apache.greeter_control.types.SayHiResponse")
    public String sayHi();

    /**
     * 
     * @param requestType
     * @return
     *     returns java.lang.String
     */
    @WebMethod
    @WebResult(name = "responseType", targetNamespace = 
"http://apache.org/greeter_control/types";)
    @RequestWrapper(localName = "greetMe", targetNamespace = 
"http://apache.org/greeter_control/types";, className = 
"org.apache.greeter_control.types.GreetMe")
    @ResponseWrapper(localName = "greetMeResponse", targetNamespace = 
"http://apache.org/greeter_control/types";, className = 
"org.apache.greeter_control.types.GreetMeResponse")
    public String greetMe(
        @WebParam(name = "requestType", targetNamespace = 
"http://apache.org/greeter_control/types";)
        String requestType);

    /**
     * 
     * @param requestType
     */
    @WebMethod
    @Oneway
    @RequestWrapper(localName = "greetMeOneWay", targetNamespace = 
"http://apache.org/greeter_control/types";, className = 
"org.apache.greeter_control.types.GreetMeOneWay")
    public void greetMeOneWay(
        @WebParam(name = "requestType", targetNamespace = 
"http://apache.org/greeter_control/types";)
        String requestType);

    /**
     * 
     * @throws PingMeFault
     */
    @WebMethod
    @RequestWrapper(localName = "pingMe", targetNamespace = 
"http://apache.org/greeter_control/types";, className = 
"org.apache.greeter_control.types.PingMe")
    @ResponseWrapper(localName = "pingMeResponse", targetNamespace = 
"http://apache.org/greeter_control/types";, className = 
"org.apache.greeter_control.types.PingMeResponse")
    public void pingMe()
        throws PingMeFault
    ;

}
/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.greeter_control;

import java.util.Iterator;
import java.util.ArrayList;
import java.util.Map;
import java.util.logging.Logger;

import javax.annotation.Resource;
import javax.annotation.PreDestroy;
import javax.annotation.PostConstruct;

import javax.jws.WebService;
import javax.jws.HandlerChain;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext;
import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;


/* serviceName, portName specified in webservices.xml */
@WebService(serviceName = "SOAPService",
            portName = "SoapPort",
            endpointInterface = "org.apache.greeter_control.Greeter",
            targetNamespace = "http://apache.org/greeter_control";)
/* two handlers specified in webservices.xml */
@HandlerChain(file="handlers.xml")
public class GreeterImpl implements Greeter {

    private static final Logger LOG =
        Logger.getLogger(GreeterImpl.class.getName());

    @Resource
    private WebServiceContext context;

    @Resource(name="greeting")
    private String greeting;

    public WebServiceContext getContext() {
        return context;
    }

    @WebMethod
    @WebResult(name = "responseType", targetNamespace = 
"http://apache.org/greeter_control/types";)
    @RequestWrapper(localName = "greetMe", targetNamespace = 
"http://apache.org/greeter_control/types";, className = 
"org.apache.greeter_control.types.GreetMe")
    @ResponseWrapper(localName = "greetMeResponse", targetNamespace = 
"http://apache.org/greeter_control/types";, className = 
"org.apache.greeter_control.types.GreetMeResponse")
    public String greetMe(String me) {
        LOG.info("Invoking greetMe " + me);

        LOG.info("WebServiceContext: " + context);
        LOG.info("Principal: " + context.getUserPrincipal());
        LOG.info("Context: " + context.getMessageContext());

        MessageContext ctx = context.getMessageContext();
        Iterator iter = ctx.entrySet().iterator();
        while(iter.hasNext()) {
            Map.Entry entry = (Map.Entry)iter.next();
            System.out.println("Key: "+entry.getKey());
            System.out.println("Value: " +entry.getValue());
        }

        // just playing around

        // send foo=BAR header
        Map responseHeaders = 
            (Map)ctx.get(MessageContext.HTTP_RESPONSE_HEADERS);
        if(responseHeaders == null) { 
                        LOG.info("Can't get 
MessageContext.HTTP_RESPONSE_HEADERS from context");
        } else {
                        ArrayList values = new ArrayList();
                        values.add("BAR");
                        responseHeaders.put("foo", values);
        }
        /*
        // make return code 201
        ctx.put(MessageContext.HTTP_RESPONSE_CODE,
                new Integer(201));
        */

        return greeting + " " + me;
    }

    @PostConstruct
    public void init() {
        System.out.println(this + " PostConstruct");
    }

    @PreDestroy()
    public void destroy() {
        System.out.println(this + " PreDestroy");
    }

    public String sayHi() {
        LOG.info("Invoking sayHi ");
                return "Hi";
    }

    public void greetMeOneWay(String me){
        LOG.info("Invoking greetMeOneWay " + me);
    }


    public void pingMe()
        throws PingMeFault {
        LOG.info("Invoking pingMe ");
        throw new PingMeFault("Custom Fault", null);
    }
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements. See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership. The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License. You may obtain a copy of the License at
 
  http://www.apache.org/licenses/LICENSE-2.0
 
  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  KIND, either express or implied. See the License for the
  specific language governing permissions and limitations
  under the License.
-->
<wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/";
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
    xmlns:tns="http://apache.org/greeter_control";
    xmlns:x1="http://apache.org/greeter_control/types";
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
    xmlns:xsd="http://www.w3.org/2001/XMLSchema";
    targetNamespace="http://apache.org/greeter_control"; name="HelloWorld">
    <wsdl:types>
        <schema targetNamespace="http://apache.org/greeter_control/types"; 
            xmlns="http://www.w3.org/2001/XMLSchema"; elementFormDefault="qualified">
            <element name="sayHi">
                <complexType/>
            </element>
            <element name="sayHiResponse">
                <complexType>
                    <sequence>
                        <element name="responseType" type="xsd:string"/>
                    </sequence>
                </complexType>
            </element>
            <element name="greetMe">
                <complexType>
                    <sequence>
                        <element name="requestType" type="xsd:string"/>
                    </sequence>
                </complexType>
            </element>
            <element name="greetMeResponse">
                <complexType>
                    <sequence>
                        <element name="responseType" type="xsd:string"/>
                    </sequence>
                </complexType>
            </element>
            <element name="greetMeOneWay">
                <complexType>
                    <sequence>
                        <element name="requestType" type="xsd:string"/>
                    </sequence>
                </complexType>
            </element>
            <element name="pingMe">
                <complexType/>
            </element>
            <element name="pingMeResponse">
                <complexType/>
            </element>
            <element name="faultDetail">
                <complexType>
                    <sequence>
                        <element name="minor" type="xsd:short"/>
                        <element name="major" type="xsd:short"/>
                    </sequence>
                </complexType>
            </element>
            
        </schema>
    </wsdl:types>

   
   <wsdl:message name="sayHiRequest">
        <wsdl:part element="x1:sayHi" name="in"/>
    </wsdl:message>
    <wsdl:message name="sayHiResponse">
        <wsdl:part element="x1:sayHiResponse" name="out"/>
    </wsdl:message>
    <wsdl:message name="greetMeRequest">
        <wsdl:part element="x1:greetMe" name="in"/>
    </wsdl:message>
    <wsdl:message name="greetMeResponse">
        <wsdl:part element="x1:greetMeResponse" name="out"/>
    </wsdl:message>
    <wsdl:message name="greetMeOneWayRequest">
        <wsdl:part element="x1:greetMeOneWay" name="in"/>
    </wsdl:message>
    <wsdl:message name="pingMeRequest">
    <wsdl:part name="in" element="x1:pingMe"/>
    </wsdl:message>
    <wsdl:message name="pingMeResponse">
        <wsdl:part name="out" element="x1:pingMeResponse"/>
    </wsdl:message>        
    <wsdl:message name="pingMeFault">
        <wsdl:part name="faultDetail" element="x1:faultDetail"/>
    </wsdl:message> 
        
    <wsdl:portType name="Greeter">
        <wsdl:operation name="sayHi">
            <wsdl:input message="tns:sayHiRequest" name="sayHiRequest"/>
            <wsdl:output message="tns:sayHiResponse" name="sayHiResponse"/>
        </wsdl:operation>
        
        <wsdl:operation name="greetMe">
            <wsdl:input message="tns:greetMeRequest" name="greetMeRequest"/>
            <wsdl:output message="tns:greetMeResponse" name="greetMeResponse"/>
        </wsdl:operation>
        
        <wsdl:operation name="greetMeOneWay">
            <wsdl:input message="tns:greetMeOneWayRequest" name="greetMeOneWayRequest"/>
        </wsdl:operation>

        <wsdl:operation name="pingMe">
            <wsdl:input name="pingMeRequest" message="tns:pingMeRequest"/>
            <wsdl:output name="pingMeResponse" message="tns:pingMeResponse"/>
            <wsdl:fault name="pingMeFault" message="tns:pingMeFault"/>
        </wsdl:operation> 
    </wsdl:portType>
    

    <wsdl:binding name="GreeterSOAPBinding" type="tns:Greeter">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        
        <wsdl:operation name="sayHi">
            <soap:operation soapAction="" style="document"/>
            <wsdl:input name="sayHiRequest">
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output name="sayHiResponse">
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
        
        <wsdl:operation name="greetMe">
            <soap:operation soapAction="" style="document"/>
            <wsdl:input name="greetMeRequest">
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output name="greetMeResponse">
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
        
        <wsdl:operation name="greetMeOneWay">
            <soap:operation soapAction="" style="document"/>
            <wsdl:input name="greetMeOneWayRequest">
                <soap:body use="literal"/>
            </wsdl:input>
        </wsdl:operation>

            <wsdl:operation name="pingMe">
            <soap:operation style="document"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>
            <wsdl:fault name="pingMeFault">
                <soap:fault name="pingMeFault" use="literal"/>
            </wsdl:fault>
        </wsdl:operation>
        
    </wsdl:binding>
  
    <wsdl:service name="GreeterService">
        <wsdl:port binding="tns:GreeterSOAPBinding" name="GreeterPort">
            <soap:address location="http://localhost:8080/SoapContext/GreeterPort"/>
            <wswa:UsingAddressing xmlns:wswa="http://www.w3.org/2005/08/addressing/wsdl"/>
        </wsdl:port>
    </wsdl:service>
   
    
</wsdl:definitions>

<?xml version="1.0"?>
<!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at
    
     http://www.apache.org/licenses/LICENSE-2.0
    
    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
-->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"; version="1.2">
<jsp:directive.page contentType="text/html"/>

<jsp:directive.page import="java.io.IOException"/>
<jsp:directive.page import="javax.naming.InitialContext"/>
<jsp:directive.page import="javax.xml.ws.Service"/>
<jsp:directive.page import="org.apache.greeter_control.Greeter"/>

<html><head><title>JAX-WS Client JSP</title></head>
<body>

<jsp:scriptlet>
        try {
            String name = request.getParameter("name");
            if (name == null) {
                name = "Unknown";
            }
            System.out.println(name);
            InitialContext ctx = new InitialContext();
            Service service = (Service)ctx.lookup("java:comp/env/services/Greeter");
            Greeter greeter = service.getPort(Greeter.class);
            out.println("WebService returned: " + greeter.greetMe(name));
        } catch (Exception e) {
            e.printStackTrace();
            IOException exception = new IOException("Error");
            exception.initCause(e);
            throw exception;
        }
</jsp:scriptlet>

</body></html>
</jsp:root>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to