Hi all
This is regarding the susantha's qustion. It seems that dims like a
patch. I give it a try, So here it is, Please some commiter have a look
at the patch. this has the patch, test case(If patch is accepted does my
test case is good enough to add as the test case for the senario).
Actually this is my first patch (It take more time than write the
code than come pass the fiewall and create the patch. Thanks for all
who helps me for that regards.)I hope the patch is correct, I follow
instruction in apache site pls let me if anthing worng.
please let me know if there are much more better ways to do thing
(regarding code,comments anything).
Any comment regarding this welcome. (I am on my toes to know what
happen to my first Patch)
Thanks for your time
regards
Srinath
rest of the mail is as follows.
1) description of logic behind the patch
2) annoted results about the patch
3) comment about result
Description of logic behind the patch
-------------------------------------
User can specify the allowed methods add - that means any overloaded
method of add or add(II),add(III).....
then they would come to the "List, allowedmethod" in the ServiceDesc
without breaking anything. (That was a big relef).
Then I make sure that only the allowed methods can enter the
method2OperationMap. I have private method
"isAllowedMethod" to help decide whether it is the a
allowedMethod(using the allowedmethod list/ it
will return true all methods if user specify as e.g. "add" to make sure
that this is backward compatible).
Then I cover the all the places that you put() on to the hashmap
method2OperationMap with the condition to to make
sure only methods we need are inside the hash map. (it is at
setTypeMappingRegistry(TypeMappingRegistry tmr) and
and createOperationForMethod(Method method)).
The effect of that code seem to be the methods that is not specified is
practially act as they do
not exists in the original code of service. That what we need I belive
!!!!!!!!!!!!!!
* to run the test please refer to the comment on the test class
Annoted result when the Calculator service in server-config.wsdd as
given below.
===============================================================================
<service name="Calculator" provider="java:RPC">
<parameter name="allowedMethods"
value="add,multiply(II),multiply([Ljava.lang.String),multiply(Ltest.data.CalcData)"/>
<parameter name="className" value="test.data.Calculator"/>
<beanMapping qname="ns:CalcData" xmlns:ns="urn:test.data"
languageSpecificType="java:test.data.CalcData"/>
</service>
add is given in the .wsdd as "add" this test or backword compatibility
*********************** test add(II) ***************************
SUCSESS Got result : 11
************************* test add(III) ************************
SUCSESS Got result : 16
Test specified simple method compatibility
multiply(II) allowed should be sucessful
****************** test multiply(II) ******************
SUCSESS Got result : 18
multiply(III) not allowed should fail
************************* test multiply(III) **************************
FAILEURE No such operation 'multiply'
- FAILEURE
AxisFault
faultCode: Server.userException
faultSubcode:
faultString: No such operation 'multiply'
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:AxisFault&#xd;&#xa; faultCode:
Server.userException&#xd;&#xa; faultSubcode: &#xd;&#xa; faultString: No
such operation 'multiply'&#xd;&#xa; faultActor: &#xd;&#xa; faultNode:
&#xd;&#xa; faultDetail: &#xd;&#xa;&#xd;&#xa;No such operation
'multiply'&#xd;&#xa;&#x9;at
org.apache.axis.message.RPCElement.deserialize(RPCElement.java:301)&#xd;&#xa;&#x9;at
org.apache.axis.message.RPCElement.getParams(RPCElement.java:347)&#xd;&#xa;&#x9;at
org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:184)&#xd;&#xa;&#x9;at
org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:334)&#xd;&#xa;&#x9;at
org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71)&#xd;&#xa;&#x9;at
org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:150)&#xd;&#xa;&#x9;at
org.apache.axis.SimpleChain.invoke(SimpleChain.java:120)&#xd;&#xa;&#x9;at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:485)&#xd;&#xa;&#x9;at
org.apache.axis.server.AxisServer.invoke(AxisServer.java:324)&#xd;&#xa;&#x9;at
org.apache.axis.transport.http.SimpleAxisWorker.execute(SimpleAxisWorker.java:435)&#xd;&#xa;&#x9;at
org.apache.axis.transport.http.SimpleAxisWorker.run(SimpleAxisWorker.java:190)&#xd;&#xa;&#x9;at
java.lang.Thread.run(Thread.java:536)&#xd;&#xa;
No such operation 'multiply'
at
org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:260)
at
org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:169)
at
org.apache.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:1083)
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 Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.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(SAXParser.java:345)
at
org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:252)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:553)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:378)
at org.apache.axis.client.Call.invokeEngine(Call.java:2583)
at org.apache.axis.client.Call.invoke(Call.java:2553)
at org.apache.axis.client.Call.invoke(Call.java:2248)
at org.apache.axis.client.Call.invoke(Call.java:2171)
at org.apache.axis.client.Call.invoke(Call.java:1691)
at
test.deployment.OverloadedMethodRestrictionTest.testSpecifiedSimpleMethod(OverloadedMethodRestrictionTest.java:175)
at
test.deployment.OverloadedMethodRestrictionTest.main(OverloadedMethodRestrictionTest.java:329)
Complex type multiply(Ldata.Calculator) allowed should be succsessful
***************** test multiply(Ldata.Calculator)******************
Got result : 3
multiply([I)allowed should be succsessful
***************** test multiply([I)******************
Got result : 362880
multiply([I[I)allowed should fail
****************** test multiply[I[I *******************
FAILEURE org.xml.sax.SAXException: Bad types (class [Ljava.lang.Object;
-> int)
- FAILEURE
AxisFault
faultCode:
{http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXException: Bad types (class
[Ljava.lang.Object; -&gt; int)
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: Bad
types (class [Ljava.lang.Object; -&gt; int)&#xd;&#xa;&#x9;at
org.apache.axis.message.RPCHandler.onStartChild(RPCHandler.java:317)&#xd;&#xa;&#x9;at
org.apache.axis.encoding.DeserializationContextImpl.startElement(DeserializationContextImpl.java:1031)&#xd;&#xa;&#x9;at
org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:198)&#xd;&#xa;&#x9;at
org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:845)&#xd;&#xa;&#x9;at
org.apache.axis.message.RPCElement.deserialize(RPCElement.java:233)&#xd;&#xa;&#x9;at
org.apache.axis.message.RPCElement.getParams(RPCElement.java:347)&#xd;&#xa;&#x9;at
org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:184)&#xd;&#xa;&#x9;at
org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:334)&#xd;&#xa;&#x9;at
org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71)&#xd;&#xa;&#x9;at
org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:150)&#xd;&#xa;&#x9;at
org.apache.axis.SimpleChain.invoke(SimpleChain.java:120)&#xd;&#xa;&#x9;at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:485)&#xd;&#xa;&#x9;at
org.apache.axis.server.AxisServer.invoke(AxisServer.java:324)&#xd;&#xa;&#x9;at
org.apache.axis.transport.http.SimpleAxisWorker.execute(SimpleAxisWorker.java:435)&#xd;&#xa;&#x9;at
org.apache.axis.transport.http.SimpleAxisWorker.run(SimpleAxisWorker.java:190)&#xd;&#xa;&#x9;at
java.lang.Thread.run(Thread.java:536)&#xd;&#xa;
org.xml.sax.SAXException: Bad types (class [Ljava.lang.Object; -> int)
at
org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:260)
at
org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:169)
at
org.apache.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:1083)
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 Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.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(SAXParser.java:345)
at
org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:252)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:553)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:378)
at org.apache.axis.client.Call.invokeEngine(Call.java:2583)
at org.apache.axis.client.Call.invoke(Call.java:2553)
at org.apache.axis.client.Call.invoke(Call.java:2248)
at org.apache.axis.client.Call.invoke(Call.java:2171)
at org.apache.axis.client.Call.invoke(Call.java:1691)
at
test.deployment.OverloadedMethodRestrictionTest.testSpecifiedArrayTypeMethod(OverloadedMethodRestrictionTest.java:262)
at
test.deployment.OverloadedMethodRestrictionTest.main(OverloadedMethodRestrictionTest.java:331)
Process terminated with exit code 0
Annoted result when the Calculator service in server-config.wsdd as
given below.
===============================================================================
<service name="Calculator" provider="java:RPC">
<parameter name="allowedMethods"
value="add,multiply(II),multiply([Ljava.lang.String),multiply(Ltest.data.CalcData)"/>
<parameter name="className" value="test.data.Calculator"/>
<beanMapping qname="ns:CalcData" xmlns:ns="urn:test.data"
languageSpecificType="java:test.data.CalcData"/>
</service>
this is allowed should be succsessful
*********************** test add(II) ***********************
SUCSESS Got result : 11
this is allowed should be succsessful
************************* test add(III) ************************
SUCSESS Got result : 16
Test specified simple method compatibility
this is not allowed should be fail
****************** test multiply(II) ******************
FAILEURE java.lang.NullPointerException *** 1)see comment at end
- FAILEURE
AxisFault
faultCode:
{http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.lang.NullPointerException
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:java.lang.NullPointerException&#xd;&#xa;&#x9;at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)&#xd;&#xa;&#x9;at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)&#xd;&#xa;&#x9;at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)&#xd;&#xa;&#x9;at
java.lang.reflect.Method.invoke(Method.java:324)&#xd;&#xa;&#x9;at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:402)&#xd;&#xa;&#x9;at
org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:309)&#xd;&#xa;&#x9;at
org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:334)&#xd;&#xa;&#x9;at
org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71)&#xd;&#xa;&#x9;at
org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:150)&#xd;&#xa;&#x9;at
org.apache.axis.SimpleChain.invoke(SimpleChain.java:120)&#xd;&#xa;&#x9;at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:485)&#xd;&#xa;&#x9;at
org.apache.axis.server.AxisServer.invoke(AxisServer.java:324)&#xd;&#xa;&#x9;at
org.apache.axis.transport.http.SimpleAxisWorker.execute(SimpleAxisWorker.java:435)&#xd;&#xa;&#x9;at
org.apache.axis.transport.http.SimpleAxisWorker.run(SimpleAxisWorker.java:190)&#xd;&#xa;&#x9;at
java.lang.Thread.run(Thread.java:536)&#xd;&#xa;
{http://xml.apache.org/axis/}isRuntimeException:true
java.lang.NullPointerException
at
org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:260)
at
org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:169)
at
org.apache.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:1083)
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 Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.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(SAXParser.java:345)
at
org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:252)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:553)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:378)
at org.apache.axis.client.Call.invokeEngine(Call.java:2583)
at org.apache.axis.client.Call.invoke(Call.java:2553)
at org.apache.axis.client.Call.invoke(Call.java:2248)
at org.apache.axis.client.Call.invoke(Call.java:2171)
at org.apache.axis.client.Call.invoke(Call.java:1691)
at
test.deployment.OverloadedMethodRestrictionTest.testSpecifiedSimpleMethod(OverloadedMethodRestrictionTest.java:154)
at
test.deployment.OverloadedMethodRestrictionTest.main(OverloadedMethodRestrictionTest.java:329)
this is allowed should be succsessful
************************* test multiply(III) **************************
SUCSESS Got result : 90
this is allowed should be succsessful
***************** test multiply(Ldata.Calculator)******************
Got result : 3
this is not allowed should be fail
***************** test multiply([I)******************
Got result : 0 *** 2)see comment at end
this is allowed should be sucsessful
****************** test multiply[I[I *******************
SUCSESS Got result : 735
Process terminated with exit code 0
comments
========
1) the error Nullpointer seem not aceptable but if you call that test on
the unaltered axis with the
multiply(III) in the service removed you get the same result. effect of
my patch is to remove the
method from the class (make it invisible). So it seems at least I do not
break anything.
I have a mail on axis-dev regarding that possible error in exising axis.
2) 1) the error Nullpointer seem not aceptable but if you call that test
on the unaltered axis with the
multiply([Llang.String) in the service removed you get the same result.
It seems the axis engine called
multiply([Llang.String[Llang.String) with the other parameter null.
effect of my patch is to remove the
method from the class (make it invisible). So it seems at least I do not
break anything.
I have a mail on axis-dev regarding that possible error in exising axis.
On Thu, 2003-07-10 at 18:25, Davanum Srinivas wrote:
> Susantha,
>
> One more tip, you can differentiate between the methods by checking their signature (see
details
> at http://java.sun.com/docs/books/tutorial/native1.1/implementing/method.html). For example
the
> following 3 methods:
>
> public int Add(int a, int b); - Can be represented as "Add(II)I"
> public long Add(long a, long b); - Can be represented as "Add(JJ)J"
> public double Add(double a, double b); - Can be represented as "Add(DD)D"
>
> If you are willing to patch Axis code to be able to distinguish between methods like
this, just
> follow normal patch process
> (http://nagoya.apache.org/wiki/apachewiki.cgi?AxisProjectPages/SubmitPatches)
>
> Thanks,
> dims
>
> --- Davanum Srinivas <dims@yahoo.com> wrote:
> > Susantha,
> >
> > There is no way to do this right now....See getSyncedOperationsForName method in
> > ServiceDesc.java
> > for details on how we implement the restriction. Maybe you can come up with a patch
for the new
> > feature.
> >
> > Thanks,
> > dims
> >
> > --- susantha <susantha@opensource.lk> wrote:
> > > Hi all,
> > >
> > > I have a class with a set of overloaded methods and I want to export few of
> > > those methods as a web service
> > >
> > > Ex:-
> > >
> > > class MyClass
> > > {
> > > public int Add(int a, int b); <---- method1
> > > public Point Add(Point a, Point b); <---- method2
> > > public Square Add(Square a, Square b);<---- method3
> > > }
> > >
> > > say I want to export only method2 as a web service.
> > >
> > > So in my wsdd file if I set AllowedMethods = "Add" all 3 methods will be allowed.
> > > How do I make only the method2 exported ?.
> > >
> > > Thanks,
> > >
> > > Susantha.
> > >
> > > ---------------
> > > Lanka Software Foundation (http://www.opensource.lk.)
> > > Promoting Open-Source Development in Sri Lanka.
> > > ---------------
> >
> >
> > =====
> > Davanum Srinivas - http://webservices.apache.org/~dims/
> >
> > __________________________________
> > Do you Yahoo!?
> > SBC Yahoo! DSL - Now only $29.95 per month!
> > http://sbc.yahoo.com
> >
>
>
> =====
> Davanum Srinivas - http://webservices.apache.org/~dims/
>
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com
>