Forum Stats

  • 3,840,371 Users
  • 2,262,594 Discussions
  • 7,901,249 Comments

Discussions

Web Service with complex data types

ScarfaceMkd
ScarfaceMkd Member Posts: 60
edited Feb 7, 2018 5:10AM in JDeveloper and ADF

Hi,

I would like to get some guidance for the following issues that i have. I need to create a web service(not consume) from a WSDL file that needs to replace another web service. So the structure of the requests and the responses needs to stay the same so the applications that consume the web services wont have to make changes. So I have 2 possible solutions and i would like to hear from you if you have any other recommendations:

1. Enable AM custom method as a service, but the problem here is that I can only use primitive types for parameters and return parameters while in the WS definition i have complex types both for parameters and return types.

2. Creating the WS from WSDL(the automatic option of jDeveloper to create the WS classes). This option works fine but the issue here is that i would like to use ADF business components for CRUD operations. Any idea how can i achieve that?

If you need anymore info please let me know.

Currently on 11.1.2.4 but we are migrating to 12.2.1.3 this month.

Thanks

Tagged:
«1

Answers

  • dvohra21
    dvohra21 Member Posts: 14,627 Gold Crown
    edited Feb 5, 2018 2:01PM

    create a web service(not consume) from a WSDL file that needs to replace another web service.

    The web service methods including return types and request parameters and parameter types would need to be the same for web service consumers to not require any modifications. What needs to be different that a new web service is required?

  • ScarfaceMkd
    ScarfaceMkd Member Posts: 60
    edited Feb 5, 2018 2:18PM

    The thing that needs to be different is the entity that provides the web services. We are developing software for a company that used some other software until now and they have clients that use their own applications and use this web service to upload data to our system and they don't want to modify their application.

  • dvohra21
    dvohra21 Member Posts: 14,627 Gold Crown
    edited Feb 5, 2018 2:34PM

    The only feature that needs to be different is the web service URL which is specified in the location element,

    which could be before:

    <definitions

      xmlns="http://schemas.xmlsoap.org/wsdl/"

      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"

      xmlns:xs="http://www.w3.org/2001/XMLSchema"

      xmlns:y="http://webservice.example/entity1"

      xmlns:ns="http://http://webservice.example/entity1/types/"

      targetNamespace="http://http://webservice.example/entity1/"

    >

       ...

       <service name="Entity1Service">

           <port name="Entity1Endpoint" binding="y:Entity1SoapHttpBinding">

             <soap:address

                location="http://localhost/entity1/entity1.asmx"/>

           </port>

       </service>

    </definitions>

    And after modification:

    <definitions

      xmlns="http://schemas.xmlsoap.org/wsdl/"

      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"

      xmlns:xs="http://www.w3.org/2001/XMLSchema"

      xmlns:y="http://webservice.example/entity2"

      xmlns:ns="http://http://webservice.example/entity2/types/"

      targetNamespace="http://http://webservice.example/entity2/"

    >

       ...

       <service name="Entity2Service">

           <port name="Entity2Endpoint" binding="y:Entity2SoapHttpBinding">

             <soap:address

                location="http://localhost/entity2/entity2.asmx"/>

           </port>

       </service>

    </definitions>

  • ScarfaceMkd
    ScarfaceMkd Member Posts: 60
    edited Feb 5, 2018 3:06PM

    Thanks for the reply but that is not what I'm after. Please refer to points 1 and 2 in the original post. I need to recreate the whole web service and the only thing i have is the WSDL.

  • PedroGabriel
    PedroGabriel Member Posts: 244 Bronze Badge
    edited Feb 5, 2018 3:19PM

    Hi,

    You can use ADF-BC to expose your CRUD operations. For that cases you have non primitive types (probably because you are creating) your class needs to implement oracle.jbo.AttributeList. Imagine you have MyClass.java with two attributes "firstName" and "lastName". You would have as follows:

    public class MyClass implements java.io.Serializable, oracle.jbo.AttributeList {

       

        private String firstName;

        private String lastName;

       

        public InitiatedProcess() {}

       

        public Object getAttribute(int i) {

            if(i == 0){

                return firstName;

            } else {

                return lastName;

            }

        }

        public Object getAttribute(String string) {

            if (string.toLowerCase().equals("firstName")) {

                return firstName;

            } else {

                return lastName;

            }

        }

        public void setAttribute(int i, Object object) {

            if (i == 0) {

                firstName = object.toString();

            } else {

                lastName= object.toString();

            }

        }

        public void setAttribute(String string, Object object) {

            if (string.toLowerCase().equals("tasknumber")) {

                firstName= object.toString();

            } else {

                lastName= object.toString();

            }

        }

        public int getAttributeCount() {

            return 2;

        }

        public int getAttributeIndexOf(String string) {

            if (string.toLowerCase().equals("firstName")) {

                return 0;

            } else {

                return 1;

            }

        }

        public String[] getAttributeNames() {

            return new String[] { "firstName", "lastName" };

        }

        public Object[] getAttributeValues() {

            return new Object[] {firstName, lastName};

        }

    }

    After doing this you are able to expose the method on Application Module that uses this class.

    Best Regards,

    Pedro Gabriel

  • ScarfaceMkd
    ScarfaceMkd Member Posts: 60
    edited Feb 5, 2018 3:46PM

    So you are saying that if i implement oracle.jbo.AttributeList in MyClass i can use it as input and return parameter in my Application Module method for example:

    public MyClass registerData(MyClass2 myParam){

         ...

    }

    and expose this as a web service?

  • PedroGabriel
    PedroGabriel Member Posts: 244 Bronze Badge
    edited Feb 5, 2018 3:51PM

    Hi,

    Yes your MyClass must implement oracle.jbo.AttributeList and override the methods I previous detailed. I have already implemented it in one of my projects.

    Best Regards,

    Pedro Gabriel

  • ScarfaceMkd
    ScarfaceMkd Member Posts: 60
    edited Feb 5, 2018 3:53PM

    Ok thanks. i'll try it first thing in the morning and will let you know how it goes.

  • dvohra21
    dvohra21 Member Posts: 14,627 Gold Crown
    edited Feb 5, 2018 6:41PM

    1. Modify the WSDL for the new "Entity".

    2. Generate a Web Service from the WSDL

    JDeveloper has the provision to automatically generate a Web service from a WSDL.

  • ScarfaceMkd
    ScarfaceMkd Member Posts: 60
    edited Feb 6, 2018 1:16PM

    I tried it. I set MyClass as a return type for my Service method but when creating the service interface i needed to provide a return parameter of type ViewObject for this method. I created programmatic view object with the same attributes as MyClass. Is that the right approach for this?

This discussion has been closed.