• Welcome to KonaKart Community Forum. Please login or sign up.
 

CreateOrder API Java vs SOAP--Error

Started by ReLLiK75, December 05, 2008, 03:54:34 am

Previous topic - Next topic

ReLLiK75


I've got the following code with I've added to the AxisExample.java file.   When I execute the class, the code completes with no errors.


       Basket[] basket=port.getBasketItemsPerCustomer(sessionId, customerId, -1);
       System.out.println("Basket count:  " + basket.length);
       port.createOrder(sessionId, basket, -1)


However, If I try to run similiar code via SOAP (return kkServerApi.createOrder ( KKSessionID, basketItems, -1 );) with the same items in the shopping cart, I get an the following error:

+      $exception   {System.Web.Services.Protocols.SoapException: java.lang.IllegalArgumentException: argument type mismatch
   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at EPCProxy.KonaKartServer.KKWSEngIfService.createOrder(String in0, Basket[] in1, Int32 in2) in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\EPCProxy\EPCProxy\Web References\KonaKartServer\Reference.cs:line 2393
   at EPCProxy.EPCProxy.createOrder() in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\EPCProxy\EPCProxy\KonaKart.cs:line 183}   System.Exception {System.Web.Services.Protocols.SoapException}


Please help!
Thanks!

ReLLiK75

Here's some more info that may help track down the problem.  I've inspected the SOAP response with Fiddler and this is what is being returned:

HTTP/1.1 500 Internal Server Error
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=utf-8
Date: Fri, 05 Dec 2008 06:05:18 GMT
Connection: close
Content-Length: 533

<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><soapenv:Fault><faultcode>soapenv:Server.userException</faultcode><faultstring>java.lang.IllegalArgumentException: java.lang.ClassCastException@fe45d3</faultstring><detail><ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">vm-xp1</ns1:hostname></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>;


How there's a class cast expection, I have no idea. I'm supplying the sessionID, an array of type Basket, and the integer value for Default Language.

ReLLiK75

One more bit of info....The tomcat trace shows the following:

ERROR (BeanPropertyTarget.java:set:135) Could not convert java.lang.Integer to bean field 'prodRelationTypeArray', type

ReLLiK75

Ahhh...how great it feels when you figure out a solution to a problem.

This one is for the .Net guys out there.

If you are using Visual Studio (I happen to use 2008) to import the konakart WSDL as a web reference, there are a few places where code doesn't get created the way it should.  In this particular case, the prodRelationTypeArray parameter was defined in the reference.cs file incorrectly.  The KK API docs show that it should be of type int[], however the code generator typed it as simply int.

This is what was causing all my errors when trying to create a order via C# SOAP.

Other places I've had issues with the Visual Studio Code generator was for objects typed as System.Nullable<Decimal>.  These would always return null values.  When I changed them to just Decimal, I would get the correct values back from the SOAP response.

Cheers!
Wayne

ReLLiK75

UPDATE--this is a bug in the WSDL.  Anyone using SOAP will have problems programmatically creating orders without changing the generated code until this WSDL bug gets corrected.

The WSDL declares prodRelationTypeArray as follows:

<element name="prodRelationTypeArray" nillable="true" type="xsd:int"/>

because the API is expecting an array of int, the WSDL needs to be changed to indicate the int should actually be an array of ints.

Brian

I wouldn't say that it's a bug, more of a compatibility problem between Axis and your particular WSDL processor.

The WSDL is created automatically by Axis, when consumed by Axis it generates an array of int as required.

I guess that your Microsoft WSDL processing tool is incompatible with the WSDL that Axis produces here, in a similar way to the other problems you've been having, reported in this thread.

There has been a long history of incompatibilities amongst different SOAP tools so we shouldn't be too surprised.

If you have a version of the WSDL that you think works well with .NET - please feel free to contribute this, (stating version of KonaKart and version of .NET and specific wsdl tool),  to the contributions section of this forum!

Thanks,

Brian

ReLLiK75

Hi Brain...

Sure thing!  As soon as I can figure out how to iron out all the issues that I'm having trying to go from java to .Net

Do you know how to disable the RPC encoding?  I think this may also clear up some issues

Wayne

Brian

Hi,

I would check out the Axis docs to see what you can do to configure those services.

-Brian

ReLLiK75

Any issues with using KK with Axis2 or a later version of tomcat?

Brian

In the next release we'll ship with tomcat 6.0.18 - no problems going up to this that I recall.

I haven't tried KonaKart with Axis 2 although we have plans to upgrade to a more recent version of Axis within the not-too-distant future.

-Brian


ReLLiK75

I'm stuck!

I'm noticing that when I call createOrder,  it seems like the finalPrice attributes are are not getting received by the SOAP engine and, as a result, when the order object is returned the subTotal attributes are = 0.00.  I have verified all this using Fiddler to watch the actual SOAP messages as their being sent/received.  This means I can't accurately call getOrderTotals because the subtotal object comes back = 0.00 and my order ends up with a total price equal only to shipping + tax.

I tried adding a globalconfig section to the service-config.wsdd and setting "sendMultiRefs" to false, but the SOAP engine didn't like the format of the SOAP message for a Basket Object (or any complex type) when I tried calling createOrder.

I then tried creating my own WSDL using the "wrapped" and "literal" switches in the java2WSDL util, but the resulting C# code that gets created when using the wsdl util on the new wsdl doesn't recognize the responses back from the SOAP engine, so something as simple as doesCustomerExistForEmail, which should return a true, get's a false value in my .net test client application.

I'm at a critical point in my development and really need to find a way to work around these SOAP issues.  I've tried everything I know how to do short of extracting the jars, decompiling the classes, and changing the KKWSEngIf class.

Please help!

Thanks!
Wayne