Custom serialization in blazeds

Hi,
I'm using blazeds along with flex on the client side.
I have to deal with custom serialization (typically, sending a java.util.Currency object to the client).
I found out about the PropertyProxy/PropertyProxyRegistry, and managed to serialize thing the way I want.
I still have a few questions, though:
- The PropertyProxy interface defines a clone() method. When and why is this method called?
- What is this "default instance" concept in properties proxy?
- Can I fairly assume that the subclassed BeanProxy I wrote and instantiated will be shared among all threads?
Phrased differently: should implementations of PropertyProxy be written to be thread safe?
Everything suggests that they should, but I'd just like to be totally sure about this one.
I also have a question on serialization on the flex client side, but I'm not quite sure this is the correct forum to be asking it:
- Is there any PropertyProxy/PropertyProxyRegistry mechanism in flex in order to handle custom (de)serialization? We might not always be able/want to be using IExternalizable in flex.
Thanks

Hey Olivier,
These are great questions.
PropertyProxy's play two roles - the first is to control how EVERY instance of a complex type should be described for serialization, the second is to control how just this ONE instance of a complex type should be described for serialization.
The PropertyProxyRegistry simply maps a type (class or interface) to an instance of some PropertyProxy implementation. This serves as a reusable "template" that can be used for EVERY instance of a complex type as they pass through the serializer. (This avoids the wasteful creation of new PropertyProxy's just to introspect an instance of a complex type).
However, perhaps you have a special requirement for just ONE instance of your complex type. In this scenario you look up the appropriate PropertyProxy for the complex type - but you need to make some specific adjustment say, excluding some property but just this once, for your value. In this scenario the PropertyProxy acts as a wrapper and the value serves as the default instance of the PropertyProxy. The serializer will see the value is wrapped in a PropertyProxy and will not consult the PropertyProxyRegistry.
Now, the problem is that you don't want to modify the template PropertyProxy instance in the registry as that would impact EVERY other instance. So, you can clone the PropertyProxy for your ONE instance and make the adjustment.
If you didn't care about the state of the template PropertyProxy in the registry, you could also simply construct your own PropertyProxy instance and use that to wrap your value.
Since the template PropertyProxy instances are shared across threads, then they should not be modified in an unsafe manner. Generally, however, it's not a concern as template PropertyProxy instances are not modified after construction and the value to be introspected is passed in as an argument to the utility methods (rather than being part of the PropertyProxy state).
Pete

Similar Messages

  • [svn] 1455: add sql date types and custom serialization tests

    Revision: 1455
    Author: [email protected]
    Date: 2008-04-29 11:56:59 -0700 (Tue, 29 Apr 2008)
    Log Message:
    add sql date types and custom serialization tests
    Modified Paths:
    blazeds/trunk/qa/apps/qa-regress/testsuites/mxunit/tests/remotingService/dataTypes/DateTy pesTest.mxml
    Added Paths:
    blazeds/trunk/qa/apps/qa-regress/testsuites/mxunit/tests/remotingService/dataTypes/MyFile Ref.as
    blazeds/trunk/qa/apps/qa-regress/testsuites/mxunit/tests/remotingService/dataTypes/Proper tyProxyTest.mxml
    blazeds/trunk/qa/apps/qa-regress/testsuites/mxunit/tests/remotingService/dataTypes/SQLDat eTypesTest.mxml

    Congrats to Shanky and Durval!
     SQL Server General and Database Engine Technical Guru - June 2014  
    Shanky
    SQL Server: What does Column Compressed Page Count Value Signify
    in DMV Sys.dm_db_index_physical_stats ?
    DB: "Interesting and detailed"
    DRC: "• This is a good article and provides details of each and every step and the output with explanation. Very well formed and great information. • We can modify the create table query with “DEFAULT VALUES". CREATE TABLE [dbo].[INDEXCOMPRESSION](
    [C1] [int] IDENTITY(1,1) NOT NULL, [C2] [char](50) NULL DEFAULT 'DEFAULT TEST DATA' ) ON [PRIMARY]"
    GO: "Very informative and well formed article as Said says.. Thanks for that great ressource. "
    Durval Ramos
    How to get row counts for all Tables
    GO: "As usual Durva has one of the best articles about SQL Server General and Database Engine articles! Thanks, buddy!" "
    Jinchun Chen: "Another great tip!"
    PT: "Nice tip" 
    Ed Price: "Good topic, formatting, and use of images. This would be far better if the examples didn't require the black bars in the images. So it would be better to scrub the data before taking the screenshots. Still a good article. Thank you!"
    Ed Price, Azure & Power BI Customer Program Manager (Blog,
    Small Basic,
    Wiki Ninjas,
    Wiki)
    Answer an interesting question?
    Create a wiki article about it!

  • ++Custom Serialization with Complex Data type (Nested Classes)

    Hi,
    We have a scenario wherein we need to write CUSTOM SERIALIZERS for complex datatypes like INVOICE & ORDER (INVOICE inturn has ADDRESS type among others, ORDER has ADDRESS type, a COLLECTION of type ORDERITEM each of which are Java Classes in themselves)
    The example of Custom Serializer given in the SOA AS Dev Guide http://download.oracle.com/docs/cd/B31017_01/web.1013/b28975/custserial.htm#CFHHIBCA)
    shows only a simple java type used for serialization and deserialization.
    Can anyone please help us out by sharing any example depicting the CUSTOM SERIALIZERs for COMPLEX DATA TYPES?
    Thanks in advance,
    Pavan.

    Hello,
    Could you please post the code of your classes in the forum (at least the interfaces) ?
    Regards
    Tugdual Grall

  • Custom "serializer" in ReplicatedCache not set on CacheHandler

    I tried to configure custom Serializer on ReplicatedCache service (supposed to be new feature in Coherence 3.4) in tangosol-coherence-override.xml like this:
    <coherence>
    <cluster-config>
    <services>
    <service id="1">
    <service-type>ReplicatedCache</service-type>
    <service-component>ReplicatedCache</service-component>
    <init-params>
    <init-param id="5">
    <param-name>serializer/class-name</param-name>
    <param-value>com.marand.cache.io.ThinTypeMapSerializer</param-value>
    </init-param>
    </init-params>
    </service>
    </services>
    </cluster-config>
    </coherence>
    ... and it is actually being picked up and used, but as soon as starting 2nd node in a cluster, when it should synchronize the replicated caches, I get an Exception:
    java.lang.ClassCastException: com.marand.cache.io.ThinTypeMapSerializer cannot be cast to com.tangosol.io.DefaultSerializer
         at com.tangosol.util.ExternalizableHelper.deserializeInternal(ExternalizableHelper.java:2643)
         at com.tangosol.util.ExternalizableHelper.fromBinary(ExternalizableHelper.java:256)
         at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.ReplicatedCache$ConverterFromInternal.convert(ReplicatedCache.CDB:6)
         at com.tangosol.util.ConverterCollections$ConverterMapEvent.getNewValue(ConverterCollections.java:3594)
         at com.tangosol.coherence.component.util.cacheHandler.CatalogHandler.entryInserted(CatalogHandler.CDB:3)
         at com.tangosol.util.MapEvent.dispatch(MapEvent.java:191)
         at com.tangosol.util.MapEvent.dispatch(MapEvent.java:164)
         at com.tangosol.util.MapListenerSupport.fireEvent(MapListenerSupport.java:556)
         at com.tangosol.coherence.component.util.CacheHandler.onLeaseUpdate(CacheHandler.CDB:83)
         at com.tangosol.coherence.component.util.CacheHandler.populateCache(CacheHandler.CDB:33)
         at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.ReplicatedCache$CacheUpdate.onReceived(ReplicatedCache.CDB:5)
         at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.onMessage(Grid.CDB:9)
         at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.onNotify(Grid.CDB:130)
         at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.ReplicatedCache.onNotify(ReplicatedCache.CDB:3)
         at com.tangosol.coherence.component.util.Daemon.run(Daemon.CDB:37)
         at java.lang.Thread.run(Thread.java:619)
    ...Investigating further I found that the deserialization works correctly - the ReplicatedCache$ConverterFromInternal is actually using the custom Serializer when
    trying to deserialize the ReplicatedCache$CacheUpdate message. But the sending node constructs the ReplicatedCache$CacheUpdate message and populates it using the CacheHandler.populateUpdateMessage method which in turn uses the CacheHandler's serializer and that is not being set in the process of initialization - see the following methods:
    ReplicatedCache.instantiateCacheHandler & ReplicatedCache.cloneCacheHandler
    Am I correct that this is a bug?
    Peter

    Unfortunately DefaultSerializer is final ;-(
    ...I think that CatalogHandler (a subclass of CacheHandler) which is also being used as the 1st handler in ReplicatedCache is the right suspect. This is definitely always using DefaultSerializer.

  • Help on custom Serialization

    Hey all,
    I'm trying to design a networked whiteboard application and the thought I had was instead of trying to send a vector of the points the user has drawn, I send a BufferedImage with transparent background and the server simply draws each user's "layer" one on top of the other and distributes this to all clients. Obviously the problem here is that BufferedImage does not implement Serializable, and I don't have the knowledge to write custom serialization methods, can someone help me out?
    ~nill

    Convert the image to a byte array:
    Here is a small example...
         imageFile = new File("image.jpg");
         fis = new FileInputStream(imageFile);
         length = imageFile.length();
         if(length>Integer.MAX_VALUE)
              System.out.println("IMAGE FILE IS TOO LARGE");
         imageByteArray = new byte[(int)length];
         int offset=0;
         int numRead=0;
         while(offset<imageByteArray.length &&(numRead=fis.read(imageByteArray,offset, imageByteArray.length-offset))>=0)
              offset+=numRead;
         if(offset<imageByteArray.length)
              throw new IOException("Could not completely read file: "+imageFile.getName());
         fis.close();
    Hope that this helps..

  • Custom serializer/deserializer in Weblogic 9 web service

    We are able to select XML from the database which is properly formatted to the schema definition of the method return type. Therefore, the serialization/deserialization of XML to JAVA and then back to XML does not make sense.
    Is there a way to use a custom serializer/deserializer in a Weblogic 9.1 web service like we could do in Weblogic 8.1? I have read where the 8.1 web services are still supported but we would like to migrate everything over now. In 8.1 the serializer/deserializer was defined in the deployment descriptor. However, I have seen nothing of this kind in Weblogic 9 documentation and all of those classes are now marked Deprecated.
    Any help is greatly appreciated. Thanks!

    Why dont you try removing the ejb-jar.xml and using annotations. You can use @JndiName and @FileGeneration annotations, this should work ...
    -Jesus

  • Creating a custom serializer for SOAP

    Hi guys, i'm wondering if someone could help me. I'm trying to create a custom serializer for a class with SOAP and I'm geeting the following SOAPException:
    Fault Code = SOAP-ENV:Server.Exception:
    Fault String = org/apache/soap/util/xml/Serializer
    I'm able to deploy the service with no problems.
    I'm using a very simple example in which I'm only trying to get a Person class from the service. here is the deployment descriptor:
    <isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment" id="urn:PersonService">
      <isd:provider type="java"
                    scope="Application"
                    methods="getPerson">
        <isd:java class="app.PersonService" static="false"/>
      </isd:provider>
      <isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListener>
      <isd:mappings>
        <isd:map encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                 xmlns:x="urn:person"
                 qname="x:person"
                 javaType="app.Person"
                 java2XMLClassName="app.PersonSerializer"
                 xml2JavaClassName="app.PersonSerializer"/>
      </isd:mappings> 
    </isd:service>here is the PersonService.java:
    package app;
    public class PersonService {
        /** Creates a new instance of GetPerson */
        public PersonService() {
        public Person getPerson() {
            return new Person("joe", "something");
    }here is the Person.java:
    package app;
    public class Person {
        public String firstName;
        public String lastName;
        /** Creates a new instance of Person */
        public Person() {   
        public Person(String firstName, String lastName) {
            this.firstName = firstName;
            this.lastName = lastName;
    }here is the PersonSerializer.java:
    package app;
    import java.io.IOException;
    import java.io.Writer;
    import org.apache.soap.encoding.soapenc.SoapEncUtils;
    import org.apache.soap.rpc.Parameter;
    import org.apache.soap.rpc.RPCConstants;
    import org.apache.soap.rpc.SOAPContext;
    import org.apache.soap.util.Bean;
    import org.apache.soap.util.StringUtils;
    import org.apache.soap.util.xml.DOMUtils;
    import org.apache.soap.util.xml.Deserializer;
    import org.apache.soap.util.xml.NSStack;
    import org.apache.soap.util.xml.QName;
    import org.apache.soap.util.xml.Serializer;
    import org.apache.soap.util.xml.XMLJavaMappingRegistry;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    public class PersonSerializer implements Serializer, Deserializer {
        /** Creates a new instance of PersonSerializer */
        public PersonSerializer() {
        public void marshall(String string, Class aClass, Object object, Object object0, Writer writer, NSStack nSStack, XMLJavaMappingRegistry xMLJavaMappingRegistry, SOAPContext sOAPContext) throws IllegalArgumentException, IOException {
            nSStack.pushScope();
            SoapEncUtils.generateStructureHeader(string, aClass, sOAPContext, writer, nSStack, xMLJavaMappingRegistry);
            writer.write(StringUtils.lineSeparator);
            Person person = (Person)object;
            String firstName = person.firstName;
            String lastName = person.lastName;
            xMLJavaMappingRegistry.marshall(string, String.class, firstName, "firstName", writer, nSStack, sOAPContext);
            writer.write(StringUtils.lineSeparator);
            xMLJavaMappingRegistry.marshall(string, Integer.class, lastName, "lastName", writer, nSStack, sOAPContext);
            writer.write(StringUtils.lineSeparator);
            writer.write("</" + sOAPContext + '>');   
            nSStack.popScope();
        public Bean unmarshall(String string, QName qName, Node node, XMLJavaMappingRegistry xMLJavaMappingRegistry, SOAPContext sOAPContext) throws IllegalArgumentException {
            Element root = (Element)node;
            Element childElement = DOMUtils.getFirstChildElement(root);
            Person target;
            try {
                target = (Person)Person.class.newInstance();
            } catch (Exception e) {
                throw new IllegalArgumentException("Problem instantiating bean: " + e.getMessage());
            while(childElement !=null) {
                Bean paramBean = xMLJavaMappingRegistry.unmarshall(string, RPCConstants.Q_ELEM_PARAMETER, childElement, sOAPContext);
                Parameter param = (Parameter)paramBean.value;
                String tagName = childElement.getTagName();
                if(tagName.equals("firstName")) {
                    target.firstName = (String)param.getValue();
                } else if(tagName.equals("lastName")) {
                    target.lastName = (String)param.getValue();
                childElement = DOMUtils.getNextSiblingElement(childElement);
            return new Bean(Person.class, target);
    }and finally here is the client app class that calls the service, the GetPersonClient.java:
    package app;
    import java.net.MalformedURLException;
    import java.net.URL;
    import org.apache.soap.Constants;
    import org.apache.soap.Fault;
    import org.apache.soap.SOAPException;
    import org.apache.soap.encoding.SOAPMappingRegistry;
    import org.apache.soap.rpc.Call;
    import org.apache.soap.rpc.Parameter;
    import org.apache.soap.rpc.Response;
    import org.apache.soap.util.xml.QName;
    public class GetPersonClient {
        /** Creates a new instance of GetPersonClient */
        public GetPersonClient() {
        public static void main(String[] args) {
            SOAPMappingRegistry registry = new SOAPMappingRegistry();
            PersonSerializer personSerializer = new PersonSerializer();
            // Map the types.
            registry.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:person", "person"), Person.class, personSerializer, personSerializer);
    // Build the call.
            Call call = new Call();
            call.setSOAPMappingRegistry(registry);
            call.setTargetObjectURI("urn:PersonService");
            call.setMethodName("getPerson");
            call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
            Response response;
            try {
               response = call.invoke(new URL("http://localhost:8090/soap/servlet/rpcrouter"), "");
            } catch (SOAPException e) {
                System.err.println("Caught SOAPException: " + e.getMessage());
                e.printStackTrace();
                return;
            } catch (MalformedURLException ex) {
                ex.printStackTrace();
                return;
            if (!response.generatedFault()) {
                Parameter parameter = response.getReturnValue();
                Person person = (Person)parameter.getValue();
                if ( person != null ) {
                    System.out.println( person.firstName + " " + person.lastName );
            } else {
                Fault fault = response.getFault();
                System.err.println("Generated fault: ");
                System.out.println("  Fault Code   = " + fault.getFaultCode());
                System.out.println("  Fault String = " + fault.getFaultString());
    }if someone could help me i would be grateful.
    cheers
    nmc

    Is the problem in your 'marshall' method? You seem to be using Integer.class instead of String.class for the 'lastName' parameter...

  • [svn:bz-3.x] 20488: backporting BLZ-435 fix for AMFX serialization from BLAZEDS trunk to blazeds 3 .x

    Revision: 20488
    Revision: 20488
    Author:   [email protected]
    Date:     2011-02-28 11:52:50 -0800 (Mon, 28 Feb 2011)
    Log Message:
    backporting BLZ-435 fix for AMFX serialization from BLAZEDS trunk to blazeds 3.x
    checkintests pass
    Ticket Links:
        http://bugs.adobe.com/jira/browse/BLZ-435
    Modified Paths:
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/io/amfx/AmfxInput.java

  • When are custom serializer/deserializers necessary?

    I've written a generic client for webservices which, when given a WSDL file, operation name and list of parameter values, can call any webservice the returns a string value (usually a string of xml).
    The client has worked fine against several webservices that take simple typed input parameters like strings and numbers, however I now need to call a webservice that takes custom, complexType parameters for input and am completely stumped as to how this should work.
    Will I need to come up with an equivalent java class to map to the complexType parameters and write a custom serializer to map between the two? Or is there an easy way to input values and an existing serializer that could be used?
    Excerpts from the wsdl file:
    Types -
    <s:element name="AddressSearch">
    <s:complexType>
    <s:sequence>
    <s:element minOccurs="0" maxOccurs="1" name="BuildingNumber" type="s:string" />
    <s:element minOccurs="0" maxOccurs="1" name="BuildingName" type="s:string" />
    <s:element minOccurs="0" maxOccurs="1" name="Street" type="s:string" />
    <s:element minOccurs="0" maxOccurs="1" name="PostCode" type="s:string" />
    <s:element minOccurs="0" maxOccurs="1" name="Auth" type="s:string" />
    </s:sequence>
    </s:complexType>
    </s:element>
    <s:element name="AddressSearchResponse">
    <s:complexType>
    <s:sequence>
    <s:element minOccurs="0" maxOccurs="1" name="AddressSearchResult" type="s:string" />
    </s:sequence>
    </s:complexType>
    </s:element>
    Message Definitions-
    <wsdl:message name="AddressSearchSoapIn">
    <wsdl:part name="parameters" element="tns:AddressSearch" />
    </wsdl:message>
    <wsdl:message name="AddressSearchSoapOut">
    <wsdl:part name="parameters" element="tns:AddressSearchResponse" />
    </wsdl:message>
    Operation-
    <wsdl:operation name="AddressSearch">
    <wsdl:input message="tns:AddressSearchSoapIn" />
    <wsdl:output message="tns:AddressSearchSoapOut" />
    </wsdl:operation>

    You have not specified which type of client have you developed?
    I'm giving you solution for java clients.
    1) Either create DII client in java which includes only a single java file with few lines of code. You can download j2ee tutorials(free fom sun's website). The sample code is mention in it.
    2) generate web client from server itself( like sun server or any server which you are using). The code generated by server automatically contains necessary serializer/deserializers .
    custom serializer/deserializers are necessary only if you have complex type defined in your WSDL file.
    If u don't find the necessary code in that tutorials,let me know, I'll send to you.

  • Remote distributed scheme with custom serializer does not work

    HI,
    I have a remote scheme invoked through TcpExtend which is distributed-scheme. Now if I have a custom serializer attached the first node in the cluster comes up without a problem but not the second one onwards. It gives the following exception...
    2010-11-01 18:17:27.302/21.532 Oracle Coherence EE 3.6.0.1 <Error> (thread=Distr
    ibutedCache:extend-service, member=2): The service "extend-service" is configure
    d to use serializer <our package>.JavaSerialisation@562
    78964, which appears to be different from the serializer used by Member(Id=1, Ti
    mestamp=2010-11-01 18:14:35.066, Address=192.168.113.56:8088, MachineId=6456, Lo
    cation=site:oursite.corp,machine:mg-ldn-d0002,process:540, Role=Exe4jRuntimeWi
    nLauncher).
    java.io.IOException: invalid type: 119
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.g
    rid.PartitionedService$PartitionConfig.readObject(PartitionedService.CDB:25)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.g
    rid.PartitionedService$MemberWelcome.read(PartitionedService.CDB:20)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.G
    rid.deserializeMessage(Grid.CDB:42)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.G
    rid.onNotify(Grid.CDB:31)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.g
    rid.PartitionedService.onNotify(PartitionedService.CDB:3)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.g
    rid.partitionedService.PartitionedCache.onNotify(PartitionedCache.CDB:3)
    at com.tangosol.coherence.component.util.Daemon.run(Daemon.CDB:42)
    at java.lang.Thread.run(Thread.java:619)
    Stopping the extend-service service.
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.G
    rid.start(Grid.CDB:6)2010-11-01 18:17:27.302/21.532 Oracle Coherence EE 3.6.0.1
    <D5> (thread=DistributedCache:extend-service, member=2): Service extend-service
    left the cluster

    Config file contents follow...
    The server config - <cache-config>
    <caching-scheme-mapping>
    <cache-mapping>
    <cache-name>client-request-cache</cache-name>
    <scheme-name>extend-scheme</scheme-name>
    </cache-mapping>
    </caching-scheme-mapping>
    <caching-schemes>
    <proxy-scheme>
    <service-name>ExtendTcpProxyService</service-name>
    <acceptor-config>
    <tcp-acceptor>
    <local-address>
              <address>localhost</address>
              <port>9098</port>
    </local-address>
    </tcp-acceptor>
    <serializer>
    <class-name>test.JavaSerialisation</class-name>
    </serializer>
    </acceptor-config>
    </proxy-scheme>
    <distributed-scheme>
    <scheme-name>extend-scheme</scheme-name>
    <service-name>extend-service</service-name>
    <serializer>
    <class-name>test.JavaSerialisation</class-name>
    </serializer>
    <backing-map-scheme>
    <local-scheme/>
    </backing-map-scheme>
    <autostart>false</autostart>
    </distributed-scheme>
    </caching-schemes>
    </cache-config>
    Client - config is as follows
    <cache-config>
    <caching-scheme-mapping>
    <cache-mapping>
    <cache-name>client-request-cache</cache-name>
    <scheme-name>client-extend-scheme</scheme-name>
    </cache-mapping>
    </caching-scheme-mapping>
    <caching-schemes>
    <remote-cache-scheme>
    <scheme-name>client-extend-scheme</scheme-name>
    <service-name>ExtendTcpCacheService</service-name>
    <initiator-config>
    <tcp-initiator>
    <remote-addresses>
    <socket-address>
                   <address>localhost</address>
                   <port>9099</port>
              </socket-address>
    </remote-addresses>
                   <connect-timeout>5s</connect-timeout>
    </tcp-initiator>
    <outgoing-message-handler>
    <!-- If server has not responded by 100s, then will time out -->
    <request-timeout>100s</request-timeout>
    </outgoing-message-handler>
    <serializer>
    <instance>
    <class-name>test.JavaSerialisation</class-name>
    </instance>
    </serializer>
    </initiator-config>
    </remote-cache-scheme>
    </caching-schemes>
    </cache-config>
    Edited by: 807718 on 08-Nov-2010 10:14
    Edited by: 807718 on 08-Nov-2010 10:15

  • Custom Serialization

    Hello,
    In My development I have to make a Web service which shout returns Complex Type.
    From Otn as follows
    http://otn.oracle.com/tech/webservices/htdocs/samples/serialize/index.html
    I found how to do it through editing WSDL/Web.xml file.
    But when i Testing my Web service it occures
    following
    errors:
    04/03/15 12:54:04 java.lang.IllegalArgumentException: No Serializer found to serialize a 'java.util.HashMap' using encoding style 'http://schemas.xmlsoap.org/soap/encoding/'.
    04/03/15 12:54:04      at org.apache.soap.util.xml.XMLJavaMappingRegistry.querySerializer(XMLJavaMappingRegistry.java:157)
    04/03/15 12:54:04      at org.apache.soap.encoding.soapenc.ParameterSerializer.marshall(ParameterSerializer.java:106)
    04/03/15 12:54:04      at org.apache.soap.rpc.RPCMessage.marshall(RPCMessage.java:265)
    04/03/15 12:54:04      at org.apache.soap.Body.marshall(Body.java:148)
    04/03/15 12:54:04      at org.apache.soap.Envelope.marshall(Envelope.java:203)
    04/03/15 12:54:04      at org.apache.soap.Envelope.marshall(Envelope.java:162)
    04/03/15 12:54:04      at oracle.j2ee.ws.InvocationWrapper.invoke(InvocationWrapper.java:442)
    04/03/15 12:54:04      at oracle.j2ee.ws.RpcWebService.doGetRequest(RpcWebService.java:624)
    04/03/15 12:54:04      at oracle.j2ee.ws.BaseWebService.doGet(BaseWebService.java:1117)
    04/03/15 12:54:04      at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    04/03/15 12:54:04      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    04/03/15 12:54:04      at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
    04/03/15 12:54:04      at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:356)
    04/03/15 12:54:04      at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:614)
    04/03/15 12:54:04      at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
    04/03/15 12:54:04      at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:784)
    04/03/15 12:54:04      at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
    04/03/15 12:54:04      at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
    04/03/15 12:54:04      at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
    04/03/15 12:54:04      at java.lang.Thread.run(Thread.java:536)
    I am using Jdev 10g preview with Embebded Oc4j Server.
    Where should be the Problem?
    Thank'x in Advance.

    hi,
    I worked with service exposed as a webservice accepting and returning the HashMap as parameter. Its working with me.
    I will provide you with the code. go thru it. let me know if you have any queries.
    client code
    package com.hash.map.service;
    import java.util.HashMap;
    import javax.xml.rpc.encoding.DeserializerFactory;
    import org.apache.axis.client.Call;
    import org.apache.axis.client.Service;
    import org.apache.axis.encoding.XMLType;
    import org.apache.axis.utils.Options;
    import org.apache.axis.encoding.ser.BeanSerializerFactory;
    import org.apache.axis.encoding.ser.BeanDeserializerFactory;
    import javax.xml.rpc.ParameterMode;
    import javax.xml.namespace.QName;
    public class HashMapServiceClient
    public HashMapServiceClient()
    public static void main(String str[])
    try{
    String endPoint = "http://localhost:8080/axis/servlet/AxisServlet";
    Service service = new Service();
    Call call = (Call)service.createCall();
    call.setTargetEndpointAddress(new java.net.URL(endPoint));
    QName qNameIn = new QName("http://util.java","HashMap");
    call.addParameter(qNameIn,qNameIn,HashMap.class,ParameterMode.IN);
    call.setOperationStyle("rpc");
    call.setReturnClass(HashMap.class);
    //call.registerTypeMapping(HashMap.class,qNameIn,BeanSerialzerFactory.class,BeanDeserializerFactory.class);
    call.setOperationName((new QName("MyHashMapService","getHashMap")));
    HashMap hashMap = new HashMap();
    hashMap.put("name","Harish");
    hashMap.put("age","27");
    HashMap map = (HashMap)call.invoke(new Object[] {hashMap});
    System.out.println("Name changed-->" + (String)map.get("name"));
    System.out.println("Age changed-->" + (String)map.get("age"));
    }catch(Exception e)
    e.printStackTrace();
    wsdd
    <?xml version="1.0" encoding="UTF-8"?>
    <deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
    <service name="MyHashMapService" provider="java:RPC">
    <parameter name="allowedMethods" value="getHashMap"/>
    <parameter name="className" value="com.hash.map.service.HashMapService"/>
    </service>
    </deployment>
    service
    package com.hash.map.service;
    import java.util.HashMap;
    public class HashMapService
    public HashMapService()
    public HashMap getHashMap(HashMap hashMap)
    System.out.println("Service Started");
    HashMap map = hashMap;
    String strName = (String)map.get("name");
    String strAge = (String)map.get("age");
    map.put("name","Kiran");
    map.put("age","24");
    System.out.println("Service Ended");
    return map;
    }

  • Custom serialization - could you do this?

    Hi
    I'll describe a partially hypothetical situation to allow me to ask the questions I want with some context.
    Let's say someone gave you the responsibility of implementing the following API with the specified contract:
    * Convert <code>object</code> to a serialized format and save in the file
    * <code>saveDestination</code>. You are free to choose the serialization format.
    public void serializeAndSave(java.io.Serializable object, java.io.File saveDestination);
    * Deserialize objects serialized by the <code>serializeAndSave()</code> method.
    public java.io.Serializable deserialize(java.io.File file);
    Additionally, let's say the following were conditions and restrictions were specified by the person asking you to implement these methods:
    * The version of the class for <code>object</code> or any of the super-classses in its class hierarchy or the type of any fields will never change.
    * The fields of <code>object</code> will probably be private. Fields consistent with the java.io.Serializable contract, must be serialied (for instance, transient fields do not need to be serialized).
    * You will never have any information about how any declared methods in <code>object</code> relate to declared fields, so you cannot rely on declared methods for getting field values when serializing or setting field values when deserializing.
    * You will never have information about how parameters in declared constructors relate to declared fields, so you cannot rely on declared constructors for setting field values when deserializing.
    * Besides the java.io.Serializable interface and the contract specified by Java when implementing the Serializable interface (eg. empty constructor), <code>object</code> will not necessarily conform to any interface or API that you will have prior knowledge of.
    * <code>object</code> may have an inheritance hierarchy to any depth. Super-classes in the class hierarchy may have fields too.
    * Super-classes in the object hierarchy, and their fields, are subject to the same conditions and constraints described here for <code>object</code>
    OK, there's a description of the hypothetical task someone has asked you to complete.
    Luckily, this is very easy to do. You can simply rely on Java's inbuilt serialization mechanisms. You can use java.io.ObjectOutputStream and java.io.ObjectInputStream - it's all very easy. Java's inbuilt serizlization/deserialization has no problem with private fields and no problems with super-classe fields even if private.
    Now let's say I changed your task by changing the contract for the serializeAndSave() method as follows:
    * Convert <code>object</code> to an XML serialization format and save in the file
    * <code>saveDestination</code>.
    public void serializeAndSave(java.io.Serializable object, java.io.File saveDestination);
    Notice that the class must now be serialized in XML format*.
    How would you implement the serializeAndSave() and deserialize() methods now? In particular:
    * In serialzeAndSave(), how would you obtain the values of private fields in any of the super-classes in the object hierarchy?
    * In deserialize(), assuming you succussfully implemented the serializeAndSave() method, how would you set the value of any of the private fields in <code>object</code> or any of the super-classes in <code>object</codes>'s class hierarchy?
    Cheers.

    >>>
    What you're proposing is a feeble solution, but if you insist on using it, it's genuinely laughably trivial to implement. What have you been doing for the last 15 years?
    <<<
    Yeah been getting that a lot. Funny thing is, no-one can back it up.
    Here's your opportunity for you to show that you are right and I a wrong. Provide the implementation for showValueOfA(), setValueOfA(), setValueForB(). I'll go out on a limb right now and tell you that you cannot do it, despite you trying to make out that you have a complete understanding of the technical issue at hand.
    package com;
    import java.lang.reflect.Field;
    public final class DisplayUnderstanding{
         public static void showFields(Data data){
              Class clazz = null;
              Field[] fields = null;
              Field field = null;
              clazz = data.getClass();
              fields = clazz.getDeclaredFields();
              for(int i = 0, n = fields.length; i < n; ++i){
                   field = fields;
                   System.out.println(field.getName() + ": " + field.getType());
         * Will write to <code>System.out</code> the value of the field <code>a</code>
         * in the instance <code>data</code>.
         public static void showValueOfA(Data data){
              /* IMPLEMENTATION REQUIRED */
         * Will change the value of the field <code>a</code> in the instance
         * <code>data</code> to <code>value</code>.
         public static void setValueOfA(Data data,int value){
              /* IMPLEMENTATION REQUIRED */
         * Will change the value of the field <code>b</code> in the instance
         * <code>data</code> to <code>value</code>.
         public static void setValueOfB(Data data,int value){
              /* IMPLEMENTATION REQUIRED */
         public static class Data extends AbstractData{
              private int b = 0;
              public Data(int a,int b){
                   super(a);
                   this.b = b;
         public static abstract class AbstractData{
              private int a = 0;
              public AbstractData(int a){
                   this.a = a;

  • Oracle TopLink as a Custom Serializer in a Webservice tutorial question

    Tutorial link: http://www.oracle.com/technology/products/ias/toplink/technical/tips/jaxRpc11/index.htm
    Has anyone successfuly completed that tutorial using Toplink and JDeveloper 10.1.3? If so I have some questions for you. If not, then it could be possible there is a bug in the IDE with the automatic creation of serializers. I read in the documentation for Oracle, that the serializer classes are to have default constructors but none of the IDE auto-generated serializers do however.
    Surya

    If anyone is interested, I have recreated the Toplink part and the directory structures including the source code and the compiled classes. All that is to be done is to create the web service. I can send it to whoever is interested in trying to solve this problem.
    I am going to give it a shot at creating the service through the IDE or creating it separately through the command prompt and see how it goes.

  • Customizing ActionScript - Java serialization?

    Hi,
    I wonder how to customize what ActionScript class is serialized to what Java object, overriding BlazeDS's defaults.
    I have a Java class where I would like an ActionScript ArrayCollection to serialize to a custom class.
    To illustrate, normally I might have a class on the server like this:
    public MyClass {
    public void updateRecords(java.util.List[Widget]) {...}
    When this is invoked from a remote Flex client, passing an ArrayCollection as the method parameter, BlazeDS serializes that ArrayCollection into a Java List, and everything works fine.
    Suppose, however, that I have the above method signature defined in the following way:
    public MyClass {
    public void updateRecords(MyCustomCollection[Widget]) {... }
    In that situation, I'd like to be able to specify a custom serializer that takes an ActionScript ArrayCollection and serializes it into MyCustomCollection. In fact, what I'd really like to do is to use this serializer every time a Java class' interface contains MyCustomCollection.
    I looked into flex.messaging.io.TypeMarshaller, but couldn't quite figure out how to use it for that purpose. 
    Thanks,
    -- Frank

    >
    How Java Serialization works internally which algorithm it uses to serialize/deserailaize the objects?
    >
    See the Java Object Serialization Specification
    http://docs.oracle.com/javase/6/docs/platform/serialization/spec/protocol.html
    And are you aware that you have never marked a single one of your 119 previous questions as answered?
    Total Questions: 119 (119 unresolved)
    Are all of those questions really unanswered? Or have you just forgotten to mark them ANSWERED.
    Please begin revisiting your large number of previous posts and marking them ANSWERED as appropriate. This is important for several reasons. First because forum volunteers need to focus on unanswered questions - it wastes their time to read thru threads and respond to posts that have actually already been answered since the original poster isn't even going to pay attention to any new replies. That time could have been better spent helping users that have REAL unanswered questions on the forum.
    Second, when someone like yourself has large numbers of unanswered questions it basically sends a signal to the volunteers that the person posting the question may not even be reading or responding to the replies the volunteers may make. This leads some volunteers to decide to not even bother responding - why should they spend their time trying to help someone who won't even acknowledge the help that they get?
    Third, other people that have the same problem you had find your posts but never see them answered. So they never know if the information provided by the volunteers solved your problem or not. When you mark your questions answered it helps others with the same problem.
    Thanks.

  • Explicity mapping between ActionScript and Java objects for the BlazeDS Messaging Service

    The BlazeDS documentation shows how to explicitly map between ActionScript and Java objects. For example, this works fine for RPC services, e.g.
    import flash.utils.IExternalizable;
    import flash.utils.IDataInput;
    import flash.utils.IDataOutput;
    [Bindable]
    [RemoteClass(alias="javaclass.User")]
    public class User implements IExternalizable {
            public var id : String;
            public var secret : String;
            public function User() {
            public function readExternal(input : IDataInput) : void {
                    id = input.readObject() as String;
            public function writeExternal(output : IDataOutput) : void {
                    output.writeObject(id);
    and
    import java.io.Externalizable;
    import java.io.IOException;
    import java.io.ObjectInput;
    import java.io.ObjectOutput;
    import java.util.HashSet;
    import java.util.Iterator;
    import java.util.Set;
    public class User implements Externalizable {
        protected String id;
        protected String secret;
        public String getId() {
            return id;
        public void setId(String id) {
            this.id = id;
        public String getSecret() {
            return secret;
        public void setSecret(String secret) {
            this.secret = secret;
        public void readExternal(ObjectInput in) throws IOException,
                    ClassNotFoundException {
            id = (String) in.readObject();
        public void writeExternal(ObjectOutput out) throws IOException {
            out.writeObject(id);
    If I called an RPC service that returns a User, the secret is not sent over the wire.  Is it also possible to do this for the messaging service? That is, if I create a custom messaging adapter and use the function below, can I also prevent secret from being sent?
    MessageBroker messageBroker = MessageBroker.getMessageBroker(null);
    AsyncMessage message = new AsyncMessage();
    message.setDestination("MyMessagingService");
    message.setClientId(UUIDUtils.createUUID());
    message.setMessageId(UUIDUtils.createUUID());
    User user = new User();
    user.setId("id");
    user.setSecret("secret");
    message.setBody(user);
    messageBroker.routeMessageToService(message, null);

    Hi Martin. The way that AMF serialization/deserialization works for BlazeDS is the same regardless of which service is being used, so yes that code will work for messaging as well. On the server, the serialization/deserialization of messages happens at the endpoint. For an incoming message for example, the endpoint deserializes the message and then hands it off to the MessageBroker which decides which service/destination to deliver the message to.
    That was a good question. Thanks for asking it. Lots of people are used to doing custom serialization/deserialization with the RPC services (RemoteObject/RemotingService) but I'm not sure everyone realizes they can do this for messaging as well.
    -Alex

Maybe you are looking for

  • Deploying Custom Office 2013, Uninstalling Office 2010

    We've just recently moved to SCCM for application and OS deployment, so we're setting up applications to be deployed through SCCM for the very first time. I've read a few guides to deploying Office 2013, and the majority of them follow the same proce

  • Conversion from txt  to csv

    Hi, As a part of our project we are generating a text file containing the query output, it is in the following format.. | contributor | x | url | =========================================================================== | _:b0 | "Norm Walsh" | <htt

  • How to remove prefix from AD group names in ldap auth. provider?

    Hi all, I'm using weblogic 10.3.5 and LDAP authentication provider for accessing microsoft AD. Group names in AD are created and look like this: PREFIX_basic_user, PREFIX_advanced_user... but enterprise roles in ADF application are created like this:

  • Exam Guide: Exam 1Z0-051 (Oracle Press).

    Hi, I am planning to appear in the 1Z0-051 test. and got the book (OCA Oracle Database 11g SQL Fundamentals I Exam Guide: Exam 1Z0-051 (Oracle Press). this is an old copy, and does not have the CD with the sample exam. Are the questions on the exam C

  • Adobe creative suite 5

    1. I have adobe creative suite 5. it can be on 2 computers, correct? (active on 2?) 2. I have it on my desktop (win 7 64 bit) I want to put it on my surface pro 3 (windows 8); is it compatible? 3. I have 5 discs, is that correct? (adobe acrobat 9 pro