users@jax-rpc.java.net

Correct client file

From: kathy walsh <Kathleen.Walsh_at_Sun.COM>
Date: Wed, 03 Nov 2004 20:51:06 -0500

Ryan-
Here is the correct file-
The serializers are the same-

Verify that it works in your environment
and let me know-
kathy


public class RyanClient {

private String BODY_NAMESPACE_VALUE = "urn:com.test.webservice/wsdl";

public void testDIIComplexType() {
        try {

            // Create and send multiple Datum objects via stub.
            TDatum data = new TDatum("one", "two");
            TDatum data2 = new TDatum("three", "four");
            TDatum[] arrayofTDatum = new TDatum[]{data, data2};

            TData tdata = new TData(arrayofTDatum);

            String ENCODING_STYLE_PROPERTY = "javax.xml.rpc.encodingstyle.namespace.uri";
            String serviceName = "TestWebService";
            String portName = "TestWebServicePort";
            Service service = null;
            QName port = null;
            ServiceFactory factory = ServiceFactory.newInstance();
            service = factory.createService(wsdlURL, new QName(BODY_NAMESPACE_VALUE, serviceName));
            port = new QName(BODY_NAMESPACE_VALUE, portName);
            QName operation = new QName(BODY_NAMESPACE_VALUE, "handleData");

            getRegistry(service);


            Call call = service.createCall(port, operation);
            call.setProperty(Call.SOAPACTION_USE_PROPERTY, new Boolean(true));
            call.setProperty(Call.SOAPACTION_URI_PROPERTY, "TestWebService/handleData");
            call.setProperty(ENCODING_STYLE_PROPERTY, "");
            call.setProperty(Call.OPERATION_STYLE_PROPERTY, "document");
            Object[] params = new Object[]{tdata};
            call.invokeOneWay(params);

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


    public TypeMappingRegistry getRegistry(Service service) {
        TypeMappingRegistry registry = service.getTypeMappingRegistry();

        TypeMapping mapping12 = registry.getTypeMapping(SOAP12Constants.NS_SOAP_ENCODING);
        TypeMapping mapping = registry.getTypeMapping(SOAPConstants.NS_SOAP_ENCODING);
        TypeMapping mapping2 = registry.getTypeMapping("");
        {
            QName type = new QName("urn:com.test.webservice/types", "data");
            CombinedSerializer serializer = new customer_tests.dii_complex_doclit.client.TData_LiteralSerializer(type, "", DONT_ENCODE_TYPE);
            registerSerializer(mapping2, customer_tests.dii_complex_doclit.client.TData.class, type, serializer);
        }
        {
            QName type = new QName("urn:com.test.webservice/types", "tDatum");
            CombinedSerializer serializer = new customer_tests.dii_complex_doclit.client.TDatum_LiteralSerializer(type, "", DONT_ENCODE_TYPE);
            registerSerializer(mapping2, customer_tests.dii_complex_doclit.client.TDatum.class, type, serializer);
        }
        return registry;
    }

    private static void registerSerializer(TypeMapping mapping, Class javaType, QName xmlType,
                                           Serializer ser) {
        mapping.register(javaType, xmlType, new SingletonSerializerFactory(ser),
                new SingletonDeserializerFactory((Deserializer) ser));
    }

}



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net