Skip to Main Content

Java Development Tools

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!

Web Service with complex data types

ScarfaceMkdFeb 5 2018 — edited Feb 7 2018

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

Comments

Alex Keh-Oracle

Did you add the required Fluent API (i.e. HasMaxLength(x > 2000)) so that ODP.NET EF Core can map a byte[] to a BLOB?

user606112

My fluent API looks like this:

        protected override void OnModelCreating(ModelBuilder modelBuilder)

        {

            //Default - Schema: HR

            modelBuilder.HasDefaultSchema("HR");

            // Customer-Configuration

            modelBuilder.Entity<Customer>().Property(c => c.CompanyName).HasColumnType("varchar2");

            modelBuilder.Entity<Customer>().Property(c => c.CompanyName).HasMaxLength(40);

            modelBuilder.Entity<Customer>().Property(c => c.Ludsys).IsConcurrencyToken();

            // Order-Configuration

            modelBuilder.Entity<Order>().Property(o => o.Ludsys).IsConcurrencyToken();

            // OrderDetail-Configuration

            modelBuilder.Entity<OrderDetail>().Property(od => od.Ludsys).IsConcurrencyToken();

            // Product-Configuration

            modelBuilder.Entity<Product>().Property(p => p.ProductName).HasColumnType("varchar2");

            modelBuilder.Entity<Product>().Property(p => p.ProductName).HasMaxLength(40);

            modelBuilder.Entity<Product>().Property(p => p.Ludsys).IsConcurrencyToken();

            // Picture-Configuration

            modelBuilder.Entity<Picture>().Property(p => p.Bild).HasColumnType("blob");

            modelBuilder.Entity<Product>().Property(p => p.ProductName).HasMaxLength(6000000); // 6MB

            modelBuilder.Entity<Picture>().Property(p => p.Ludsys).IsConcurrencyToken();

            // Beziehungen der DbSets untereinander

            modelBuilder.Entity<Customer>().HasMany(c => c.Orders).WithOne(o => o.Customer);

            modelBuilder.Entity<Order>().HasMany(o => o.OrderDetails).WithOne(od => od.Order);

            modelBuilder.Entity<OrderDetail>().HasMany(od => od.Pictures).WithOne(p => p.OrderDetail);

            modelBuilder.Entity<Product>().HasMany(p => p.OrderDetails).WithOne(od => od.Product);

        } // OnModelCreating

Alex Keh-Oracle

Have you tried adding the required HasMaxLength(x > 2000) Fluent API to the following line:

       modelBuilder.Entity<Picture>().Property(p => p.Bild).HasColumnType("blob");

This Fluent API is required as per the documentation.

user606112

I tried 3 variants:

only: modelBuilder.Entity<Picture>().Property(p => p.Bild).HasColumnType("blob");

           

only: modelBuilder.Entity<Product>().Property(p => p.ProductName).HasMaxLength(6000000); // 6MB

both: modelBuilder.Entity<Picture>().Property(p => p.Bild).HasColumnType("blob");

         modelBuilder.Entity<Product>().Property(p => p.ProductName).HasMaxLength(6000000); // 6MB

I get always: ORA-01460

Alex Keh-Oracle
Answer

Have you tried the HasMaxLength on the Bild property, not the ProductName?

modelBuilder.Entity<Picture>().Property(p => p.Bild).HasMaxLength(6000000);

It should work with the HasMaxLength, but without the HasColumnType.

Marked as Answer by user606112 · Sep 27 2020
user606112

Hallo Alex,

thank you very much for your help. Only the following property is necessary.

modelBuilder.Entity<Picture>().Property(p => p.Bild).HasMaxLength(6000000);

I did much copy and paste to resolve the problem, so that I didn't see the wrong columnname "productname".

Now all is working pretty .

With kind regards! Günter Hoormann

Alex Keh-Oracle

Hi Gunter,

Glad to hear it works for you. Which DB version are you using?

My team hadn't seen this error before when we tested similar scenarios.

user606112

Hallo Alex,

I use DB-Version as below to create my Test-DB:

BANNER

-------------------------------------------------------------------

Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production

BANNER_FULL

-------------------------------------------------------------------

Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production

Version 18.4.0.0.0

BANNER_LEGACY

-------------------------------------------------------------------

Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production

I created the DB by application in VisualStudio 2019 using the following nuget-packages:

Util1.JPG

DB looks like this:

Util3.JPG

Util4.JPG

I tested EF Core 3.1 using packages:

Util2.JPG

Actual Fluent-API:

    protected override void OnModelCreating(ModelBuilder modelBuilder)

    {

        //Default - Schema: HR

        modelBuilder.HasDefaultSchema("HR");

        // Customer-Configuration

        modelBuilder.Entity\<Customer>().Property(c => c.CompanyName).HasMaxLength(40);

        modelBuilder.Entity\<Customer>().Property(c => c.Ludsys).IsConcurrencyToken();

        // Order-Configuration

        modelBuilder.Entity\<Order>().Property(o => o.Ludsys).IsConcurrencyToken();

        // OrderDetail-Configuration

        modelBuilder.Entity\<OrderDetail>().Property(od => od.Ludsys).IsConcurrencyToken();

        // Product-Configuration

        modelBuilder.Entity\<Product>().Property(p => p.ProductName).HasMaxLength(40);

        modelBuilder.Entity\<Product>().Property(p => p.Ludsys).IsConcurrencyToken();

        //Picture - Configuration

        modelBuilder.Entity\<Picture>().Property(p => p.Bild).HasMaxLength(6000000); // 6MB

        modelBuilder.Entity\<Picture>().Property(p => p.Ludsys).IsConcurrencyToken();

        // Beziehungen der DbSets untereinander

        modelBuilder.Entity\<Customer>().HasMany(c => c.Orders).WithOne(o => o.Customer);

        modelBuilder.Entity\<Order>().HasMany(o => o.OrderDetails).WithOne(od => od.Order);

        modelBuilder.Entity\<OrderDetail>().HasMany(od => od.Pictures).WithOne(p => p.OrderDetail);

        modelBuilder.Entity\<Product>().HasMany(p => p.OrderDetails).WithOne(od => od.Product);

    } // OnModelCreating

For ludsys column I created some trigger like this:

-- Customers

create or replace trigger trg_Customers_Ludsys

before insert or update on "Customers"

for each row

begin

:new."Ludsys" := sysdate;

end trg_Customers_Ludsys;

/

I hope this will help you.

Günter

1 - 8
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Mar 7 2018
Added on Feb 5 2018
11 comments
314 views