Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Failed to execute 'atob' on 'Window'

Sylvain-RAug 9 2018 — edited Aug 9 2018

Hello there,

JET Version: 4.2.0

Type: Hybrid

Tests: Browser(Chrom, Safari and Firefox) and real devices (iOS and Android)

I have a bunch of code that get a Base64 html code set from a REST and stored it the rootViewModel (undecoded).

In my specified viewModel I get it back, decode it and bind it to my view as:

myViewModel:

var myBase64 = window.atob(rootViewModel.myBase64);

self.myDecodedBase64 = ko.observable(myBase64);

my view:

<div data-bind="html: myDecodedBase64"></div>

It is working fine on view loading(first time) and displays well , but when I refresh the page it throws this exception:

pastedImage_1.png

I've tried to load it on self.handleBindingsApplied, on self.handleAttached, on self.handleActivated and of course primary in my viewModel.

This base64 HTML needs to be updated in the application on the fly.

Same behaviour in browser and in real devices.

Any idea what I'm doing wrong?

Thanks in advance.

Any idea?

Comments

dvohra21

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

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

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

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

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

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

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

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

dvohra21

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

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?

PedroGabriel

Hi,

In your programmatic View Object you can have custom methods and have them exposed instead of the hole view object.

Imagine you want to create, update and delete a Customer. You can create your custom methods in two different ways:

  • Custom methods in View Objects java classes
  • Custom methods in Application Module java classes
    • In this case you can rely on View Object java classes to build your operations

In both cases you can expose them in the Application Module as you want.

You just need to implement oracle.jbo.AttributeList class for your custom classes for the following ones is out-of-the-box:

  • primitive Java type
  • oracle.jbo.server.ViewRowImpl
  • java.util.List
  • oracle.jbo.AttributeList

Best Regards,

Pedro Gabriel

1 - 11

Post Details

Added on Aug 9 2018
2 comments
2,226 views