axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Soactive Inc <soact...@gmail.com>
Subject ProxyService implementation Issues (Axis 1.2RC3)
Date Sat, 23 Apr 2005 20:02:48 GMT
Environment: Apache Tomcat 5.0.24, JDK 1.4.2, Apache Axis 1.2RC3

I am using the ProxyService provided in the samples package as a
starting point for implementing my own ProxyService class that would
act as a proxy for web services. Using this design, I am able to
connect to some services that happen to reside on the same axis server
as the proxy service but having some issues when I try to connect to
external services - e.g. http://www.xignite.com/xInsider.asmx?WSDL.
Please note that the client seems to be working just fine (simply
change binding address in the code to the endpoint URL) if I bypass
the proxy. The exception I am getting indicates that its not even
reaching the endpoint (note 404 error) - I did ensure that I am able
to manually access the URL for both the service address as well as the
WSDL file. Any pointers to resolving this issue is much appreciated.

I am first appending the exception I am getting and then the rest of my code.

Thanks,
-Arun

****************************************************************************************
EXCEPTION
****************************************************************************************

##### Printing Request Message....
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="htt
p://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap
env:Body><ns1:GetOfficers
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/
" xmlns:ns1="http://www.xignite.com/services/"><IssuerIdentifier
xsi:type="xsd:string">IBM
</IssuerIdentifier><IssuerIdentifierType
xsi:type="xsd:string">Symbol</IssuerIdentifierTyp
e></ns1:GetOfficers></soapenv:Body></soapenv:Envelope>##### Request
URL: http://localhost:
8080/axis/services/ProxyService
AxisFault
 faultCode: {http://xml.apache.org/axis/}HTTP
 faultSubcode:
 faultString: (404)Object Not Found
 faultActor:
 faultNode:
 faultDetail:
        {}string:return code:  404
&lt;html&gt;&lt;head&gt;&lt;title&gt;Site Not Found&lt;/title&gt;&lt;/head&gt;
&lt;body&gt;No web site is configured at this address.&lt;/body&gt;&lt;/html&gt;
        {http://xml.apache.org/axis/}HttpErrorCode:404

(404)Object Not Found
        at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:221)

        at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:128)
        at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationConte
xt.java:1077)
        at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown
Source)
        at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown
Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher
.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Sour
ce)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at javax.xml.parsers.SAXParser.parse(Unknown Source)
        at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.ja
va:225)
        at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:645)
        at org.apache.axis.Message.getSOAPEnvelope(Message.java:424)
        at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecke
r.java:62)
        at org.apache.axis.client.AxisClient.invoke(AxisClient.java:173)
        at org.apache.axis.client.Call.invokeEngine(Call.java:2737)
        at org.apache.axis.client.Call.invoke(Call.java:2720)
        at org.apache.axis.client.Call.invoke(Call.java:2396)
        at org.apache.axis.client.Call.invoke(Call.java:2319)
        at org.apache.axis.client.Call.invoke(Call.java:1776)
        at org.apache.jsp.jsp.admin.ServiceDetail_jsp.invokeXigniteService(ServiceDetail_j
sp.java:340)
        at org.apache.jsp.jsp.admin.ServiceDetail_jsp._jspService(ServiceDetail_jsp.java:5
02)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)

        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFil
terChain.java:237)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain
.java:157)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.jav
a:703)
        at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.
java:589)
        at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.ja
va:499)
        at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)

        at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:581)
        at org.apache.struts.tiles.TilesUtilImpl.doInclude(TilesUtilImpl.java:137)
        at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:177)
        at org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:756)
        at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:
881)
        at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:473)
        at 
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)

        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFil
terChain.java:237)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain
.java:157)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.jav
a:703)
        at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispat
cher.java:463)
        at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.
java:398)
        at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.ja
va:312)
        at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)

        at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.j
ava:274)
        at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesReque
stProcessor.java:254)
        at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequest
Processor.java:309)
        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1480)
        at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:506)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFil
terChain.java:237)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain
.java:157)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
214)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.j
ava:104)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextVal
ve.java:198)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:
152)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.j
ava:104)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.j
ava:104)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.j
ava:102)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:10
9)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.j
ava:104)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
        at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:793)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnecti
on(Http11Protocol.java:702)
        at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:6
44)
        at java.lang.Thread.run(Thread.java:536)

****************************************************************************************
ProxyService.java
****************************************************************************************
/*
 * Copyright 2001-2004 The Apache Software Foundation.
 *
 * Licensed 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.
 */

import org.apache.axis.AxisFault;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.transport.http.HTTPConstants;

import javax.servlet.http.HttpServletRequest;
import javax.xml.soap.SOAPMessage;
import java.net.URL;

public class ProxyService {
    /**
     * Process the given message, treating it as raw XML.
     */
    public void proxyService(SOAPEnvelope env1, SOAPEnvelope env2)
            throws AxisFault {
        try {
            // Get the current Message Context
            MessageContext context = MessageContext.getCurrentContext();

            System.out.println("##### Printing Request Message....");
            SOAPMessage message = context.getMessage();
            message.writeTo(System.out);

            HttpServletRequest servletRequest =
                    (HttpServletRequest)
context.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
            System.out.println("##### Request URL: " +
servletRequest.getRequestURL());


            Service service = new Service();
            Call call = (Call) service.createCall();

            // NOW set the client's URL
            call.setTargetEndpointAddress(new
URL("http://www.xignite.com/xInsider.asmx?WSDL"));
            call.setProperty(Call.SOAPACTION_USE_PROPERTY, new Boolean(true));
            call.setProperty(Call.SOAPACTION_URI_PROPERTY,
"http://www.xignite.com/services/GetOfficers");
            call.setRequestMessage((Message) message);

            call.invoke();

            Message responseMessage = call.getResponseMessage();
            System.out.println("##### Printing Response Message....");
            responseMessage.writeTo(System.out);

            context.setResponseMessage(responseMessage);

        } catch (Exception exp) {
            throw AxisFault.makeFault(exp);
        }
    }
}

****************************************************************************************
Client code
****************************************************************************************

// this method can be called from any program
    public static String invokeXigniteService(String requestStr)
throws Exception {

        System.setProperty("javax.xml.soap.MessageFactory",
"org.apache.axis.soap.MessageFactoryImpl");
        System.setProperty("javax.xml.soap.SOAPConnectionFactory",
"org.apache.axis.soap.SOAPConnectionFactoryImpl");

        // create service factory
        ServiceFactory factory = ServiceFactory.newInstance();

        // define qnames
        String targetNamespace = "http://www.xignite.com/services/";
        String schemaNamespace = "http://www.xignite.com/services/";

        QName serviceName = new QName(targetNamespace, "XigniteInsider");

        QName portName = new QName(targetNamespace, "XigniteInsiderSoap");
        QName operationName = new QName(schemaNamespace, "GetOfficers");

        // create service
        Service service = new Service();
        Call call = (Call) service.createCall();

        // set port and operation name
        call.setPortTypeName(portName);
        call.setOperationName(operationName);

        QName strQName = new QName("http://www.w3.org/2001/XMLSchema",
 "string");
        QName intQName = new QName("http://www.w3.org/2001/XMLSchema",  "int");
        QName boolQName = new
QName("http://www.w3.org/2001/XMLSchema",  "boolean");

        call.addParameter("IssuerIdentifier", strQName, ParameterMode.IN);
        call.addParameter("IssuerIdentifierType", strQName, ParameterMode.IN);

        // return type
			//call.setReturnType(org.apache.axis.Constants.XSD_STRING);
			call.setReturnType(new QName(targetNamespace, "Roster"), Roster.class);
			call.setReturnQName(new QName("", "GetOfficersResult"));
			
			// register type mapping
			call.registerTypeMapping(Roster.class, new QName(targetNamespace,
"Roster"), BeanSerializerFactory.class,
BeanDeserializerFactory.class);
			call.registerTypeMapping(Address.class, new QName(targetNamespace,
"Address"), BeanSerializerFactory.class,
BeanDeserializerFactory.class);
			call.registerTypeMapping(Security.class, new QName(targetNamespace,
"Security"), BeanSerializerFactory.class,
BeanDeserializerFactory.class);
			call.registerTypeMapping(OutcomeTypes.class, new
QName(targetNamespace, "OutcomeTypes"), BeanSerializerFactory.class,
BeanDeserializerFactory.class);
			call.registerTypeMapping(Role.class, new QName(targetNamespace,
"Role"), BeanSerializerFactory.class, BeanDeserializerFactory.class);
			call.registerTypeMapping(Common.class, new QName(targetNamespace,
"Common"), BeanSerializerFactory.class,
BeanDeserializerFactory.class);
			call.registerTypeMapping(Role[].class, new QName(targetNamespace,
"ArrayOfRole"), ArraySerializerFactory.class,
ArrayDeserializerFactory.class);
			
	// set end point address
        call.setTargetEndpointAddress("http://localhost:8080/axis/services/ProxyService");
	  //call.setTargetEndpointAddress("http://www.xignite.com/xInsider.asmx");

call.setProperty(call.SOAPACTION_USE_PROPERTY, new Boolean(true));

call.setProperty(call.SOAPACTION_URI_PROPERTY,
"http://www.xignite.com/services/GetOfficers");

			// execute
        // Invoke the WebService
        Roster result = (Roster) call.invoke(new Object[]{"IBM", "Symbol"});

				System.out.println("Search Query: " + requestStr);

        String resultStr = result.toString();
	  System.out.println(resultStr);

	  return resultStr;
    }

Mime
View raw message