I'm not really getting anywhere with this and don't have time to look at
the globus samplse right now, so as there seemed to be lots a people here
interested in this, maybe someone else has some time to look at the samples
Peter points to at http://www.globus.org/ogsa/releases/alpha/

I've committed the testcase I use for this into defects.ogsa package. Works
fine for me, so I'm not sure why it doesn't for Peter. Does it work for
you?

       ...ant

Anthony Elder
[EMAIL PROTECTED]
Web Services Development
IBM UK Laboratories,  Hursley Park
(+44) 01962 818320, x248320, MP208.


"Peter G. Lane" <[EMAIL PROTECTED]> on 07/03/2003 00:02:05

To:    Anthony Elder/UK/[EMAIL PROTECTED]
cc:
Subject:    Re: DII code not working anymore/dynamic stub failing



Hmmm, I don't know what to say.  I substituted in your wsif.jar and
massaged the test case so it
would work with my package hierarchy and the new namespaces we just changed
to, but I get the exact
same error with the stub code.  I am attaching my altered java file just in
case I did something stupid.

Peter

P.S.  If you're feeling curious and ambitious, you can download our
software which contains all of
our schemas and samples to test against:
http://www.globus.org/ogsa/releases/alpha/.



Anthony Elder wrote:
> Hi Peter,
>
> I hope you're not getting to put off of WSIF.  I'm a bit confused about
> which WSIF code you're running, and what patches I've already committed
for
> you. Here's the latest WSIF jar which includes the fixes from the
previous
> patches so I know exactly what you are running with.
>
> I've a test case based on the counter WSDL you initially sent and this
> really does work ok for me. It needs to set  the style in the context for
> stubs, and for the getValue call with the DII. Hopefully I can get the
stub
> based calls to mostly work this out itself based on the types of the
input
> parts next week. With the getValue call where there are no input parts
its
> hard to tell what you really want so the context will still be required,
> although a better default would be to use unwrapped, which I'll also
change
> next week.
>
> This wsif gives a SOAP request which looks more correct:
>
>  <soapenv:Body>
>   <subtract xmlns
> ="http://samples.ogsa.globus.org/counter/counter_port_type";>
>    <ns1:value xsi:type="xsd:int" xmlns:ns1
> ="http://samples.ogsa.globus.org/counter";>9</ns1:value>
>   </subtract>
>  </soapenv:Body>
>
> Anyway, hopefully this will sort out all the trouble this has been
causing
> you, please let me know how you get on.
>
>
> (See attached file: wsif.jar)(See attached file:
> CounterServiceTestCase.java)
>
>        ...ant
>
> Anthony Elder
> [EMAIL PROTECTED]
> Web Services Development
> IBM UK Laboratories,  Hursley Park
> (+44) 01962 818320, x248320, MP208.
>
>
> "Peter G. Lane" <[EMAIL PROTECTED]> on 05/03/2003 14:12:20
>
> Please respond to [EMAIL PROTECTED]
>
> To:    [EMAIL PROTECTED]
> cc:
> Subject:    Re: DII code not working anymore/dynamic stub failing
>
>
>
> This doesn't seem to help either.  I removed all code to manually unwrap
> things, and added code to
> check for wrapped style and to set the context part as you instructed
right
> before I get the stub.
> I even tried setting this before I do an executeRequestResponseOperation
()
> (which I can get to
> work), but that stops functioning too without the manual unwrapping.
>
> Peter
>
>
>
> Anthony Elder wrote:
>
>>Woh, deja vue.
>>
>>Hi Peter,
>>
>>Its not really clear why you are doing anything to do with unwrapping
>>parts? WSIF should be doing all that for you under the covers for both
>
> the
>
>>stub and DII interface. Just make the WSIF call and WSIF should work out
>
> if
>
>>you're parameters match wrapped or unwrapped parts. There are a couple of
>>circumstances where WSIF gets this wrong, I'm in the middle of trying to
>>make this more robust. but for the moment sometimes you have to tell WSIF
>>which to use. I think this is what's going wrong with you stub calls.
>>
>>You tell WSIF you want to use wrapped or unwrapped parts by setting a
>
> part
>
>>in the context method, for example this code should fix the stub problem:
>>
>>   WSIFService service =
>>      factory.getService(
>>         "bin/ogsa/counter.wsdl",
>>         "http://samples.ogsa.globus.org/counter";,
>>         "CounterService",
>>         "http://samples.ogsa.globus.org/counter/counter_port_type";,
>>         "CounterPortType");
>>
>>   WSIFMessage ctx = service.getContext();
>>   ctx.setObjectPart(
>>      WSIFConstants.CONTEXT_OPERATION_STYLE,
>>      WSIFConstants.CONTEXT_OPERATION_STYLE_WRAPPED);
>>   service.setContext(ctx);
>>
>>   CounterPortType stub =
>>      (CounterPortType) service.getStub(portName, CounterPortType.class);
>>
>>
>>      ...ant
>>
>>Anthony Elder
>>[EMAIL PROTECTED]
>>Web Services Development
>>IBM UK Laboratories,  Hursley Park
>>(+44) 01962 818320, x248320, MP208.
>>
>>
>>"Peter G. Lane" <[EMAIL PROTECTED]> on 04/03/2003 18:46:21
>>
>>Please respond to [EMAIL PROTECTED]
>>
>>To:    [EMAIL PROTECTED]
>>cc:
>>Subject:    DII code not working anymore/dynamic stub failing
>>
>>
>>
>>I'm having trouble with one of the latest nightly build jars.  I had DII
>>working last month, but recent changes seemed to have prevented further
>>success.  One thing I noticed is that unWrapPart() is deprecated.  I'm a
>>little nervous now about what I should be doing in lieu of that since I
>>use getWrappedDocLiteralPart() which is not deprecated and implies I'd
>>have to then unwrap it.  It looks like this is causing problems with the
>>DII method:
>>
>>      [java] Exception in thread "main" java.lang.ClassCastException:
>>org.apache.wsif.schema.ElementType
>>      [java]     at
>>
>
>
org.apache.wsif.providers.ProviderUtils.getComplexType(ProviderUtils.java:389)

>
>
>>      [java]     at
>>
>
>
org.apache.wsif.providers.ProviderUtils.unWrapPart(ProviderUtils.java:343)
>
>>      [java]     at
>>org.apache.wsif.util.WSIFUtils.unWrapPart(WSIFUtils.java:1355)
>>
>>
>>I'm also having trouble using getStub().  I get a proxy object which I
>>verify is of the correct interface and has the correct methods using
>>java.lang.reflect stuff, but I get an error saying that the method I'm
>>trying to call from the stub was not found in the port type:
>>
>>...
>>      [java] 3185 [main] DEBUG
>>org.globus.ogsa.client.wsif.samples.BasicCounterAdder  - Method: public
>>final int $Proxy0.add(int) throws java.rmi.RemoteException
>>...
>>      [java] org.apache.wsif.WSIFException: Method add(int) was not
>>found in portType {http://ogsa.globus.org/samples/counter}CounterPortType
>>      [java]     at
>>
>
>
org.apache.wsif.base.WSIFClientProxy.findMatchingOperation(WSIFClientProxy.java:595)

>
>
>>      [java]     at
>>org.apache.wsif.base.WSIFClientProxy.invoke(WSIFClientProxy.java:244)
>>      [java]     at $Proxy0.add(Unknown Source)
>>      [java]     at
>>
>
>
org.globus.ogsa.client.wsif.samples.BasicCounterAdder.<init>(BasicCounterAdder.java:83)

>
>
>>      [java]     at
>>
>
>
org.globus.ogsa.client.wsif.samples.BasicCounterAdder.main(BasicCounterAdder.java:101)

>
>
>>
>>
>>Thanks!
>>Peter
>>
>>
>>
>>
>
>
>
>




/**
 * CounterServiceTestCase.java
 *
 * This file was auto-generated from WSDL
 * by the Apache WSIF WSDL2Java emitter.
 */

package org.globus.ogsa.client.wsif.test;

import java.rmi.RemoteException;
import java.util.Iterator;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;

import org.apache.wsif.WSIFConstants;
import org.apache.wsif.WSIFException;
import org.apache.wsif.WSIFMessage;
import org.apache.wsif.WSIFOperation;
import org.apache.wsif.WSIFPort;
import org.apache.wsif.WSIFService;
import org.apache.wsif.WSIFServiceFactory;

import org.globus.ogsa.samples.counter.CounterPortType;

public class CounterServiceTestCase extends TestCase {

    private static final String HOST_BASE_URL = "http://127.0.0.1:8080/";;

    private static final String SAMPLES_BASE_PATH
    = "ogsa/services/samples/";

    private static final String COUNTER_SERVICE_URL
        = HOST_BASE_URL
        + SAMPLES_BASE_PATH
        + "counter/basic/CounterFactoryService/myCounter";

    private static final String WSDL_URL = COUNTER_SERVICE_URL + "?wsdl";

    private static final String SERVICE_NS
        = "http://ogsa.globus.org/samples/counter/service";;
    private static final String SERVICE_NAME = "CounterService";

    private static final String PORT_TYPE_NS
        = "http://ogsa.globus.org/samples/counter";;
    private static final String PORT_TYPE_NAME = "CounterPortType";

    public CounterServiceTestCase(String name) {
        super(name);
    }

    public static Test suite() {
        return new TestSuite(CounterServiceTestCase.class);
    }

    protected void doit1DIICounterPortType(String portName) {
        try {
            WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
            factory.automaticallyMapTypes(true);

            WSIFService service =
                factory.getService(
                    this.WSDL_URL,
                    SERVICE_NS,
                    SERVICE_NAME,
                    PORT_TYPE_NS,
                    PORT_TYPE_NAME);

            WSIFPort port = service.getPort(portName);

            executeOpAdd(port);
            executeOpSubtract(port);
            executeOpGetValue(port);

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    protected void executeOpAdd(WSIFPort wsifPort) throws WSIFException {

        WSIFOperation op = wsifPort.createOperation("add");

        WSIFMessage inMsg = op.createInputMessage();
        WSIFMessage outMsg = op.createOutputMessage();
        WSIFMessage faultMsg = op.createFaultMessage();

        // TODO: change these params to required values
        int p0 = 5;
        inMsg.setIntPart("value", p0);

        boolean success =
            op.executeRequestResponseOperation(inMsg, outMsg, faultMsg);

        if (success) {
            System.out.println("operation 'add' successfull:");
            for (Iterator i = outMsg.getPartNames(); i.hasNext();) {
                String partName = (String) i.next();
                System.out.println(partName + ": " +
                outMsg.getObjectPart(partName));
            }
        } else {
            System.err.println("operation 'add' returned a fault:");
            for (Iterator i = faultMsg.getPartNames(); i.hasNext();) {
                System.err.println(faultMsg.getObjectPart((String) i.next
            ()));
            }
        }
    }

    protected void executeOpSubtract(WSIFPort wsifPort) throws
    WSIFException {

        WSIFOperation op = wsifPort.createOperation("subtract");

        WSIFMessage inMsg = op.createInputMessage();
        WSIFMessage outMsg = op.createOutputMessage();
        WSIFMessage faultMsg = op.createFaultMessage();

        // TODO: change these params to required values
        int p0 = 0;
        inMsg.setIntPart("value", p0);

        boolean success =
            op.executeRequestResponseOperation(inMsg, outMsg, faultMsg);

        if (success) {
            System.out.println("operation 'subtract' successfull:");
            for (Iterator i = outMsg.getPartNames(); i.hasNext();) {
                String partName = (String) i.next();
                System.out.println(partName + ": " +
                outMsg.getObjectPart(partName));
            }
        } else {
            System.err.println("operation 'subtract' returned a fault:");
            for (Iterator i = faultMsg.getPartNames(); i.hasNext();) {
                System.err.println(faultMsg.getObjectPart((String) i.next
            ()));
            }
        }
    }

    protected void executeOpGetValue(WSIFPort wsifPort) throws
    WSIFException {

        WSIFOperation op = wsifPort.createOperation("getValue");

        WSIFMessage ctx = op.getContext();
        ctx.setObjectPart(
            WSIFConstants.CONTEXT_OPERATION_STYLE,
            WSIFConstants.CONTEXT_OPERATION_STYLE_WRAPPED);
        op.setContext(ctx);

        WSIFMessage inMsg = op.createInputMessage();
        WSIFMessage outMsg = op.createOutputMessage();
        WSIFMessage faultMsg = op.createFaultMessage();

        // TODO: change these params to required values
        boolean success =
            op.executeRequestResponseOperation(inMsg, outMsg, faultMsg);

        if (success) {
            System.out.println("operation 'getValue' successfull:");
            for (Iterator i = outMsg.getPartNames(); i.hasNext();) {
                String partName = (String) i.next();
                System.out.println(partName + ": " +
                outMsg.getObjectPart(partName));
            }
        } else {
            System.err.println("operation 'getValue' returned a fault:");
            for (Iterator i = faultMsg.getPartNames(); i.hasNext();) {
                System.err.println(faultMsg.getObjectPart((String) i.next
            ()));
            }
        }
    }


    protected void doit2StubCounterPortType(String portName) {
        try {
            WSIFServiceFactory factory = WSIFServiceFactory.newInstance();

            WSIFService service =
                factory.getService(
                    this.WSDL_URL,
                    SERVICE_NS,
                    SERVICE_NAME,
                    PORT_TYPE_NS,
                    PORT_TYPE_NAME);

            WSIFMessage ctx = service.getContext();
            ctx.setObjectPart(
                WSIFConstants.CONTEXT_OPERATION_STYLE,
                WSIFConstants.CONTEXT_OPERATION_STYLE_WRAPPED);
            service.setContext(ctx);

            CounterPortType stub =
                (CounterPortType) service.getStub(portName,
                CounterPortType.class);

            executeOpAdd(stub);
            executeOpSubtract(stub);
            executeOpGetValue(stub);

        } catch (Exception ex) {
            ex.printStackTrace();
            assertTrue("doit2StubCounterPortType got exception: " +
            ex.getLocalizedMessage(), false);
        }
    }

    protected void executeOpAdd(CounterPortType stub) throws
    RemoteException {

        // TODO: change these params to required values
        int p0 = 23;

        int returnValue = stub.add(p0);

        System.out.println("operation 'add' returned: " + returnValue);
//        assertTrue("operation add returned null!!", returnValue != null);
    }

    protected void executeOpSubtract(CounterPortType stub) throws
    RemoteException {

        // TODO: change these params to required values
        int p0 = 42;

        int returnValue = stub.subtract(p0);

        System.out.println("operation 'subtract' returned: " +
returnValue);
//        assertTrue("operation subtract returned null!!", returnValue !=
null);
    }

    protected void executeOpGetValue(CounterPortType stub) throws
    RemoteException {

        // TODO: change these params to required values

        int returnValue = stub.getValue();

        System.out.println("operation 'getValue' returned: " +
returnValue);
//        assertTrue("operation getValue returned null!!", returnValue !=
null);
    }

    public void testDoit1DIICounterPortTypeCounterPort() {
        doit1DIICounterPortType("CounterPort");
    }

    public void testDoit2StubCounterPortTypeCounterPort() {
        doit2StubCounterPortType("CounterPort");
    }

    public static void main(String[] args) {
        TestRunner.run(suite());
    }
}




Reply via email to