axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ZHAO <zhaoqi.en...@gmail.com>
Subject Invoke a call to Muse in Axis
Date Wed, 16 Aug 2006 08:20:23 GMT
Hello,

I want to add identification function and maintain sessions in the Muse
service. Now I have deployed one Muse service and one Axis service. I invoke
a call to Muse service from Axis implemention file.(e.g. Once the Axis
service receives a GetResourceProperty soap request, it will do the
invocation to Muse service to get the required resource property.)
The following is the code of method getResourceProperty in the Axis
generated impl file. But it dose not work, it returns a NullPointer
Exception. I don't know where the problem is. Can anyone help?
Thanks in advance.
I attach as well the WSDL file,  the GetResourceProperty.soap and
GetResourceProperty.xml.

    public
org.oasis_open.docs.wsrf._2004._06.wsrf_WS_ResourceProperties_1_2_draft_01_xsd.GetResourcePropertyResponsegetResourceProperty(
javax.xml.namespace.QName getResourcePropertyRequest) throws
java.rmi.RemoteException,
org.oasis_open.docs.wsrf._2004._06.wsrf_WS_ResourceProperties_1_2_draft_01_xsd.InvalidResourcePropertyQNameFaultType,
org.oasis_open.docs.wsrf._2004._06.wsrf_WS_ResourceProperties_1_2_draft_01_xsd.ResourceUnknownFaultType{

        try{
            String endpoint="http://localhost:8080/muse/services/router5";
            String uri = " http://example.org/services/Router5";
            InputStream is =ClassLoader.getSystemResourceAsStream
("C:/axis-1_4/samples/AxisTest1/requests/GetResourceProperty.xml");
            System.err.print ("input stream: "+is.toString());
            ServiceFactory sfactory = (org.apache.axis.client.ServiceFactory
)ServiceFactory.newInstance();

            URL wsdlURL = new
URL("http://localhost:8080/muse/services/router5?wsdl
");
            QName serviceQname = new QName("
http://example.org/services/Router5", "RouterService");
            Service service =
(org.apache.axis.client.Service)sfactory.createService(wsdlURL,
serviceQname);
            //the port name becomes the service name in the wsdd generated
by Wsdl2Java
            QName portQname = new QName("
http://example.org/services/Router5", "router5");


            Call call = (Call)service.createCall
(portQname,"GetResourceProperty");
            call.setTargetEndpointAddress(endpoint);
            call.setProperty(Call.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE);
            call.setProperty(Call.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
            call.setProperty(Call.SOAPACTION_URI_PROPERTY, uri);

            call.setProperty(Call.ENCODINGSTYLE_URI_PROPERTY, "");
            call.setProperty(Call.OPERATION_STYLE_PROPERTY, "document");
            call.setOperationName(new QName("
http://example.org/services/Router5","GetResourceProperty"));

            QName qn1=new QName("
http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.wsdl","GetResourceProperty");

//            QName qn2=new
QName("http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.wsdl
","GetResourcePropertyResponse");
            call.addParameter("ResourceId",qn1,ParameterMode.IN);
//            call.setReturnType(qn2,
org.oasis_open.docs.wsrf._2004._06.wsrf_WS_ResourceProperties_1_2_draft_01_xsd.GetResourcePropertyResponse.class);
//            QName qn3=new QName("http://example.org/services/Router5
","ResourceId");
//            String stri="ResourceId";
//            Object[] ob=(stri);
//
org.oasis_open.docs.wsrf._2004._06.wsrf_WS_ResourceProperties_1_2_draft_01_xsd.GetResourcePropertyResponseres=(
org.oasis_open.docs.wsrf._2004._06.wsrf_WS_ResourceProperties_1_2_draft_01_xsd.GetResourcePropertyResponse)call.invoke(qn3,ob);


            org.apache.axis.message.SOAPEnvelope envelope = new
org.apache.axis.message.SOAPEnvelope();
            org.apache.axis.message.SOAPBodyElement bodyelement = new
org.apache.axis.message.SOAPBodyElement(is);
            bodyelement.setNamespaceURI("http://example.org/services/Router5
");

            envelope.addBodyElement(bodyelement);
            org.apache.axis.message.SOAPEnvelope elms = (
org.apache.axis.message.SOAPEnvelope)call.invoke(envelope);
            org.apache.axis.message.SOAPBodyElement elem = elms.getFirstBody();
            String str=elem.getAsString();
            System.err.print(str);


        }
        catch(SOAPException se){
            System.err.println("SOAPException: '" + se.getMessage () + "'");
            System.err.println("  Cause:  '" +
se.getCause().getClass().getName()
+ "': " + se.getCause().getMessage());
            return null;
        }
        catch (IOException ioe)
        {
          System.err.println("IOException writing SOAPMessage:  '" +
ioe.getMessage() + "'");
          return null;
        }
        catch(Exception e){
            e.printStackTrace ();
        }

        return null;
 }


the exception posted in the server:

java.lang.NullPointerException
        at samples.AxisTest1.AxisTestSoapBindingImpl.getResourceProperty(AxisTes

tSoapBindingImpl.java:488)
        at samples.AxisTest1.AxisTestSoapBindingSkeleton.getResourceProperty
(Axi
sTestSoapBindingSkeleton.java:389)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke (Method.java:324)
        at org.apache.axis.providers.java.RPCProvider.invokeMethod(
RPCProvider.j
ava:397)
        at org.apache.axis.providers.java.RPCProvider.processMessage
(RPCProvider
.java:186)
        at org.apache.axis.providers.java.JavaProvider.invoke(
JavaProvider.java:
323)
        at org.apache.axis.strategies.InvocationStrategy.visit
(InvocationStrateg
y.java:32)
        at org.apache.axis.SimpleChain.doVisiting (SimpleChain.java:118)
        at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
        at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java
:454
)
        at org.apache.axis.server.AxisServer.invoke (AxisServer.java:281)
        at org.apache.axis.transport.http.AxisServlet.doPost(
AxisServlet.java:69
9)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:716)
        at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBas
e.java:327)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(Appl
icationFilterChain.java:200)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationF
ilterChain.java:146)
        at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperV
alve.java:209)
        at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:596)
        at org.apache.catalina.core.StandardPipeline.invoke(
StandardPipeline.jav
a:433)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java
:948)

        at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextV
alve.java:144)
        at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:596)
        at org.apache.catalina.core.StandardPipeline.invoke(
StandardPipeline.jav
a:433)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)


        at org.apache.catalina.core.StandardContext.invoke(
StandardContext.java:
2358)
        at org.apache.catalina.core.StandardHostValve.invoke(
StandardHostValve.j
ava:133)
        at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:596)
        at org.apache.catalina.valves.ErrorDispatcherValve.invoke
(ErrorDispatche
rValve.java:118)
        at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:594)
        at org.apache.catalina.valves.ErrorReportValve.invoke(
ErrorReportValve.j
ava:116)
        at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:594)
        at org.apache.catalina.core.StandardPipeline.invoke(
StandardPipeline.jav
a:433)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)


        at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineVal
ve.java:127)
        at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java :596)
        at org.apache.catalina.core.StandardPipeline.invoke(
StandardPipeline.jav
a:433)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java
:948)

        at org.apache.coyote.tomcat4.CoyoteAdapter.service (
CoyoteAdapter.java:15
2)
        at org.apache.coyote.http11.Http11Processor.process(
Http11Processor.java
:799)
        at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection( Http11Protocol.java:705)
        at org.apache.tomcat.util.net.TcpWorkerThread.runIt(
PoolTcpEndpoint.java
:577)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run
(ThreadP
ool.java:683)
        at java.lang.Thread.run(Thread.java:536)

Mime
View raw message