12 Replies Latest reply on Jul 10, 2008 9:31 AM by BKBK

    Web service invokation problem

    marekss
      Hi,
      I am having problem when consuming .net web service. This web service expects xmlobject which I create using <cfxml> tag. I have used <cfinvoke> and CreateObject without any success.
      First I get following error message: java.lang.IllegalArgumentException: argument type mismatch
      After I refresh few times (15 or so) I get following error message: java.lang.IllegalArgumentException: java.lang.ClassCastException@1645559. I am not sure wher is the problem.

      Thanks,
      Mark
        • 1. Re: Web service invokation problem
          JR "Bob" Dobbs-qSBHQ2 Level 3
          Can you post the WSDL and your code?
          • 2. Re: Web service invokation problem
            Dan Bracuk Level 5
            What do you think the phrase, "argument type mismatch" means?
            • 3. Re: Web service invokation problem
              marekss Level 1
              My method placeOrder is expecting complex datatype. There is a placeOrderString method that i tested succesfully which accepts a xml document as a string

              I am supplying xml document above with sample data and it is working with placeOrderString method using Get Http request.
              When using placeOrder and supplying same xmldocument created using <cfxml> it fails.
              Why there is a differnt error message after i refresh the page numerous times?

              Thanks for any help
              Mark
              • 4. Re: Web service invokation problem
                marekss Level 1

                Here is my code;
                <cfxml variable="xmlobject">
                <cfoutput>
                <Orders xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xmlns="" Version="1.0" xsi:noNamespaceSchemaLocation="Order.xsd">
                <Order>
                <Customer_Data>
                <SkipDupCheck>N</SkipDupCheck>
                <UserId>public</UserId>
                <SkipAddressCheck>Y</SkipAddressCheck>
                <ChainNbr />
                <StoreNbr />
                <SansNbr />
                <CustNbr />
                <BillTo>23423</BillTo>
                <ShipTo>43242</ShipTo>
                <MacAcct />
                <ZipStateCountry />
                <ShortName />
                <OneTimeShipInfo>
                <Name>Joe Test</Name>
                <Addr1>11 Test Ave</Addr1>
                <Addr2>Town Hall</Addr2>
                <Addr3 />
                <City>Bethlehem</City>
                <State>NY</State>
                <ZipPostalCode>112222323</ZipPostalCode>
                <CountryCode>US</CountryCode>
                </OneTimeShipInfo>
                <BillToOnly>N</BillToOnly>
                </Customer_Data>
                <CreditCardInfo>
                <CardNbr />
                <ExpDate />
                <AreaCode />
                <PhoneNbr />
                <Contact />
                <Trigger />
                </CreditCardInfo>
                <Deliver_Option>
                <ShipVia />
                <FreightTrm />
                <ArriveBy />
                <DeliverOn />
                <NotBefore />
                <ShipOn />
                <FreightAmt />
                <HandlingFee />
                </Deliver_Option>
                <SpecialInstructions>
                <AuthAppearance />
                <SpecInstr1 />
                <SpecInstr2 />
                <SpecInstrComments1 />
                <SpecInstrComments2 />
                <SpecInstrComments3 />
                </SpecialInstructions>
                <ReceiptDate />
                <OrderSource>DC</OrderSource>
                <OrderType>NC</OrderType>
                <RushCode>N</RushCode>
                <MarkFor>test</MarkFor>
                <CartonRound />
                <BatchNbr />
                <PrintOption />
                <StatusOverride />
                <WarehouseCode />
                <Royalty />
                <Facility />
                <SalesHurt />
                <BarCodeNumber />
                <AddSource />
                <Voucher />
                <TaxClassOver />
                <InvoiceRoute />
                <BOShipDate />
                <NotToExceed />
                <PrintBindOrderNumber />
                <ShipWOFlag />
                <WorkOrderNumber />
                <CancelDate />
                <CancelDays />
                <AdditionalDiscount />
                <Promotion />
                <CustomerPurchaseOrder>312321</CustomerPurchaseOrder>
                <OvrdDisc />
                <DatingCode />
                <OvrNetPrice />
                <AccountDiscountClassOvrd />
                <BOPref />
                <NYPPref />
                <BSBPref />
                <InvoiceCombinationPref />
                <LineItems>
                <LineItem>
                <ItemNumber>1</ItemNumber>
                <Qty>1</Qty>
                <AltTitleCode />
                <ISBN>1234567890</ISBN>
                <PromoKey />
                <NetPrice />
                <Discount />
                <FreightTerms />
                <TitleStatusOvrd>AS</TitleStatusOvrd>
                <SubstituteOvrd />
                <TransportOvrd />
                <BackOrderCanOvrd />
                </LineItem>
                </LineItems>
                </Order>
                </Orders>
                </cfoutput>
                </cfxml>
                <cfset ws_obj = CreateObject("webservice", " http://host/webservices/orderentry/orderentry.asmx?WSDL")>
                <cfdump var="#ws_obj#">
                <cfset ws_ret_ = ws_obj.placeOrder(#xmlobject#)>
                • 5. Re: Web service invokation problem
                  BKBK Adobe Community Professional & MVP
                  An XML document object created by <cfxml> is particularly a Coldfusion object. Chances are, it is unknown to .NET. What happens when you invoke the service using XML as text instead?



                  • 6. Re: Web service invokation problem
                    marekss Level 1
                    When I supply a string I get following error:
                    coldfusion.xml.rpc.ServiceProxy$ServiceMethodNotFoundException: Web service operation "placeOrder" with parameters
                    • 7. Re: Web service invokation problem
                      marekss Level 1
                      Here is a code _placeOrder.java generated using wsdl2java.exe utility:

                      /**
                      * _PlaceOrder.java
                      *
                      * This file was auto-generated from WSDL
                      * by the Apache Axis WSDL2Java emitter.
                      */

                      package com.domain.services;

                      public class _PlaceOrder implements java.io.Serializable {
                      private com.domain.services._PlaceOrder_orderData orderData;

                      public _PlaceOrder() {
                      }

                      public com.domain.services._PlaceOrder_orderData getOrderData() {
                      return orderData;
                      }

                      public void setOrderData(com.domain.services._PlaceOrder_orderData orderData) {
                      this.orderData = orderData;
                      }

                      private java.lang.Object __equalsCalc = null;
                      public synchronized boolean equals(java.lang.Object obj) {
                      if (!(obj instanceof _PlaceOrder)) return false;
                      _PlaceOrder other = (_PlaceOrder) obj;
                      if (obj == null) return false;
                      if (this == obj) return true;
                      if (__equalsCalc != null) {
                      return (__equalsCalc == obj);
                      }
                      __equalsCalc = obj;
                      boolean _equals;
                      _equals = true &&
                      ((this.orderData==null && other.getOrderData()==null) ||
                      (this.orderData!=null &&
                      this.orderData.equals(other.getOrderData())));
                      __equalsCalc = null;
                      return _equals;
                      }

                      private boolean __hashCodeCalc = false;
                      public synchronized int hashCode() {
                      if (__hashCodeCalc) {
                      return 0;
                      }
                      __hashCodeCalc = true;
                      int _hashCode = 1;
                      if (getOrderData() != null) {
                      _hashCode += getOrderData().hashCode();
                      }
                      __hashCodeCalc = false;
                      return _hashCode;
                      }

                      // Type metadata
                      private static org.apache.axis.description.TypeDesc typeDesc =
                      new org.apache.axis.description.TypeDesc(_PlaceOrder.class);

                      static {
                      typeDesc.setXmlType(new javax.xml.namespace.QName(" http://services.domain.com/", ">PlaceOrder"));
                      org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
                      elemField.setFieldName("orderData");
                      elemField.setXmlName(new javax.xml.namespace.QName(" http://services.domain.com/", "orderData"));
                      elemField.setXmlType(new javax.xml.namespace.QName(" http://services.domain.com/", ">PlaceOrder>orderData"));
                      elemField.setMinOccurs(0);
                      typeDesc.addFieldDesc(elemField);
                      }

                      /**
                      * Return type metadata object
                      */
                      public static org.apache.axis.description.TypeDesc getTypeDesc() {
                      return typeDesc;
                      }

                      /**
                      * Get Custom Serializer
                      */
                      public static org.apache.axis.encoding.Serializer getSerializer(
                      java.lang.String mechType,
                      java.lang.Class _javaType,
                      javax.xml.namespace.QName _xmlType) {
                      return
                      new org.apache.axis.encoding.ser.BeanSerializer(
                      _javaType, _xmlType, typeDesc);
                      }

                      /**
                      * Get Custom Deserializer
                      */
                      public static org.apache.axis.encoding.Deserializer getDeserializer(
                      java.lang.String mechType,
                      java.lang.Class _javaType,
                      javax.xml.namespace.QName _xmlType) {
                      return
                      new org.apache.axis.encoding.ser.BeanDeserializer(
                      _javaType, _xmlType, typeDesc);
                      }

                      }

                      }
                      • 8. Re: Web service invokation problem
                        BKBK Adobe Community Professional & MVP
                        > When I supply a string I get following error

                        What happens when you do something along these lines:

                        <cfsavecontent variable="xmlString"><?xml version="1.0" encoding="UTF-8" ?>
                        <Orders>
                        <Order>
                        ...
                        etc. etc.
                        ...
                        </Order>
                        </Orders>
                        </cfsavecontent>

                        <cfset ws_obj = CreateObject("webservice", " http://host/webservices/orderentry/orderentry.asmx?WSDL")>
                        <cfset ws_ret_ = ws_obj.placeOrder(xmlString)>


                        • 9. Re: Web service invokation problem
                          marekss Level 1
                          When I use <cfsavecontent variable="xmlobject"><?xml version="1.0" encoding="UTF-8" ?>
                          as suggested above i get following error:
                          Web service operation "placeOrder" with parameters { N public Y 23423 43242 Joe Test 11 Test Ave Town Hall Bethlehem NY 112222323 US N DC NC N} could not be found.

                          When i supply xmldocument generated by <cfxml> i get argument type mismatch. are there complex data types that can not be represented using cf structures, arrays etc.?
                          Is it possible that this web service I can consume only using .net?

                          Any help would be appreciated
                          Here is a part of the wsdl that defines placeOrder:

                          • 10. Re: Web service invokation problem
                            BKBK Adobe Community Professional & MVP
                            Just realized we've been thrashing around for nothing. There are as yet no universal standards for passing XML as arguments to Web service methods. Coldfusion has its own, as do .NET and Java.

                            The common currency among all web services is SOAP. Hence, one universal way of passing XML, from any client to a web service on any platform, is as a SOAP document.

                            In your case, you would construct a SOAP document which includes your XML. You could then pass it to the web service using <cfhttp>. I googled and found a fully worked out example in houseOfFusion.

                            • 11. Re: Web service invokation problem
                              marekss Level 1
                              Thanks so much BKBK for your help, after following your suggestions I was able to consume this web service using <cfhttp> method.
                              • 12. Re: Web service invokation problem
                                BKBK Adobe Community Professional & MVP
                                I'm glad to hear.