This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

SOAP messaging !  RSS feed

 
Manas Ahlaad
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when I write a service for implementing SOAP messaging, method in that service takes Vector only as parameter in Axis API.Its not acepting any other type as argument. Why is this so?
Service is:
package prasad.examples ;
import org.w3c.dom.Element ;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
import org.apache.axis.MessageContext ;
import java.util.Vector ;
public class MessageService1
{
public Vector echoElements(Vector elems)
{
Vector result = new Vector(elems.size());
Element elem = null;
for ( int i = 0 ; i < elems.size() ; i++ )
{
elem = (Element) elems.get(i);
System.out.println("Element=====>"+elem.toString());
result.addElement(elem);
NodeList childNodeList=elem.getChildNodes();
int nodeLength = childNodeList.getLength();
for(int k=0; k < nodeLength ; k++)
{
if(childNodeList.item(k).getNodeType() == Node.TEXT_NODE)
{
System.out.println("Node Value =====>"+childNodeList.item(k).getNodeValue());
}
else
{
System.out.println("Node Name =====>"+childNodeList.item(k));
}
}
}
return( result );
}
}

Exception in thread "main" AxisFault
faultCode: {http://xml.apache.org/axis/}Server.userException
faultString: java.lang.NoSuchMethodException: echoElementtried class: prasad.examples.MessageService1, method name: e
ement.
faultActor: null
faultDetail:
stackTrace: java.lang.NoSuchMethodException: echoElementtried class: prasad.examples.MessageService1, method na
echoElement.
at org.apache.axis.providers.java.MsgProvider.processMessage(MsgProvider.java:173)
at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:289)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:150)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:120)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:312)
at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:577)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106)
at java.lang.Thread.run(Thread.java:536)

java.lang.NoSuchMethodException: echoElementtried class: prasad.examples.MessageService1, method name: echoElement.
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:135)
at org.apache.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:904)
at org.apache.xerces.parsers.SAXParser.endElement(SAXParser.java:1403)
at org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator.java:1480)
at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1204)
at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1081)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:213)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:457)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:362)
at org.apache.axis.client.Call.invokeEngine(Call.java:2046)
at org.apache.axis.client.Call.invoke(Call.java:2016)
at org.apache.axis.client.Call.invoke(Call.java:1309)
at prasad.examples.MessageServiceClient.doit(MessageServiceClient.java:40)
at prasad.examples.MessageServiceClient.main(MessageServiceClient.java:50)

TIA
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the method is defined as taking a Vector, why would you expect it to take anything else?
What does the deployment descriptor look like?
Bill
 
Manas Ahlaad
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it doesnt allow me in the method signature to have parameters anything other than Vector. the above exception is thrown if the method signature is
Element[] messageservice(String[] ab){}
my deployment descriptor is
<deployment name="test" xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">
<service name="MessageService" provider="java:MSG">
<parameter name="className" value="prasad.examples.MessageService" />
<parameter name="allowedMethods" value="echoElements" />
</service>
</deployment>
TIA
 
Manas Ahlaad
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it doesnt allow even
Element[] messagService(Element[] ab){}
this..
for all the method signatures other than having Vector[] as argument , it compiles but throws the above runtime exception.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you're missing the point. The Vector is a Vector of elements. The goal is that you manipulate the Elements. This is because of the SOAP specification -- in the SOAP spec, it states that a SOAP body may contain more than one element -- thus the reason for a Vector.
How would you expect the system to know what you intend if you change the type of the argument? What if you decided to give it one argument instead of two? How would it know what to do in that case? This is all done through reflection, so limiting the set of acceptable parameters is the major way of making this problem tractable.
Kyle
 
Manas Ahlaad
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks kyle!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!