Announcement

Collapse
No announcement yet.

MvCall help!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    MvCall help!

    I am working on an integration between our clients MIVA based e-commerce site and their ERP system. I am attempting to make a web service call from a custom module to our web service to pass the customer order to the ERP. However this is not working and I am getting different errors depending upon the METHOD of call that I specify. I have tried all of the types but I can not get it to connect. Can you please tell me what I am doing wrong.

    I am including the module code. At this point the XML is hard coded and my plan is to build up the xml from the customer order data once I have the communication part working.

    Thank you!!!!
    Steve

    <MIVA STANDARDOUTPUTLEVEL = "" IDENT = "$Id: templateorderemails.mv 65726 2017-11-08 23:35:50Z burch $">

    <MvCOMMENT>

    </MvCOMMENT>

    <MvFUNCTION NAME = "Module_Description" PARAMETERS = "module var" STANDARDOUTPUTLEVEL = "">
    <MvASSIGN NAME = "l.module:code" VALUE = "VisualERP Interface">
    <MvASSIGN NAME = "l.module:name" VALUE = "TVisualERP Interface">
    <MvASSIGN NAME = "l.module:provider" VALUE = "Steve Whyte - Visual South">
    <MvASSIGN NAME = "l.module:version" VALUE = "9.0009">
    <MvASSIGN NAME = "l.module:api_ver" VALUE = "9.065">
    <MvASSIGN NAME = "l.module:description" VALUE = "This Module sends orders to a Web API for Visual Manufacturing">
    <MvASSIGN NAME = "l.module:features" VALUE = "fulfill">
    </MvFUNCTION>

    <MvCOMMENT>
    |
    | Store-level Module Data Support Feature (data_store)
    |
    </MvCOMMENT>

    <MvFUNCTION NAME = "Module_Install_Store" PARAMETERS = "module var" STANDARDOUTPUTLEVEL = "" ERROROUTPUTLEVEL = "">
    <MvFUNCTIONRETURN VALUE = 1>
    </MvFUNCTION>


    <MvFUNCTION NAME = "FulfillmentModule_ProcessOrder" PARAMETERS = "module var, order var" STANDARDOUTPUTLEVEL = "">

    <MvASSIGN NAME="l.body" VALUE="{'<?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.datacontract.org/2004/07/SaleClassLibrary" xmlns:ns2="http://tempuri.org/">
    <SOAP-ENV:Body>
    <ns2:CreateOrder>
    <ns2:obj>
    <ns1:Desired_Ship_Date>11/22/2018</ns1:Desired_Ship_Date>
    <ns1:Notes>TEST</ns1:Notes>
    <ns1:OrderID>TESTyyy2</ns1:OrderID>
    <ns1:OrderLines>
    <ns1:OrderLine>
    <ns1:Line_No>1</ns1:Line_No>
    <ns1:Order_ID>TESTyyy2</ns1:Order_ID>
    <ns1:Part_ID>10DC00WG</ns1:Part_ID>
    <ns1:Qty>2</ns1:Qty>
    <ns1:Service_ID> </ns1:Service_ID>
    <ns1:Unit_Price>10.99</ns1:Unit_Price>
    </ns1:OrderLine>
    </ns1:OrderLines>
    <ns1:PO>TEST123</ns1:PO>
    <ns1:Ship_Via>TEST</ns1:Ship_Via>
    <ns1:auth>
    <ns1:Password>Pass1234</ns1:Password>
    <ns1:UserName>User1234</ns1:UserName>
    </ns1:auth>
    <ns1:customer>
    <ns1:Address>?</ns1:Address>
    <ns1:Bill_to_Address>?</ns1:Bill_to_Address>
    <ns1:Bill_to_City>?</ns1:Bill_to_City>
    <ns1:Bill_to_Country>?</ns1:Bill_to_Country>
    <ns1:Bill_to_Name>?</ns1:Bill_to_Name>
    <ns1:Bill_to_State>?</ns1:Bill_to_State>
    <ns1:Bill_to_ZipCode>?</ns1:Bill_to_ZipCode>
    <ns1:City>?</ns1:City>
    <ns1:Country>?</ns1:Country>
    <ns1:CustomerID>13599</ns1:CustomerID>
    <ns1:CustomerName>?</ns1:CustomerName>
    <ns1:EmailId>?</ns1:EmailId>
    <ns1:First_Name>?</ns1:First_Name>
    <ns1:Last_Name>?</ns1:Last_Name>
    <ns1:Phone>?</ns1:Phone>
    <ns1:State>?</ns1:State>
    <ns1:ZipCode>?</ns1:ZipCode>
    </ns1:customer>
    </ns2:obj>
    </ns2:CreateOrder>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>'}">

    <MvCALL ACTION="{'http://xxx.xxx.xxx.xxx:8080/02-SaleServiceHost/SaleService.svc'}"
    METHOD="RAW" FIELDS="{l.body}"
    HEADERS="Content-type:application/soap+xml">
    <MvEVAL EXPR = "{s.callvalue}">
    </MvCALL>

    <MvFUNCTIONRETURN VALUE = 1>
    </MvFUNCTION>


    #2
    There is a tool called diagtool which enables you to turn on MvCall logging this will show you the request being sent by Miva and the response being returned This tool is included in the engine release which can be downloaded here:

    https://www.miva.com/support/downloads

    https://www.miva.com/forums/forum/de...ript-debug-log


    Here is a simple example of MvCALL which may help:

    Code:
    <MvASSIGN NAME = "g.full_request"     VALUE = "{ g.api_endpoint $ g.path }" />
    
    <MvASSIGN NAME = "g.headers" value = "{ 'X-Algolia-API-Key: XXXXXXXXXXXXXXXXXXXXXXX' $ asciichar( 13 ) $ asciichar( 10 ) }">
    <MvASSIGN NAME = "g.headers" value = "{ g.headers $ 'X-Algolia-Application-Id: CCCCCCCC' $ asciichar( 13 ) $ asciichar( 10 ) }" />
    
    
    
        <MIVA STANDARDOUTPUTLEVEL="text,html,compresswhitespace">
        <MvCAPTURE VARIABLE = "l.request_body">
        {
            "name": "brennan",
            "company" : "miva"
        }
        </MvCAPTURE>
        <MIVA STANDARDOUTPUTLEVEL="">
    
        <MIVA MvCALL_Error = "nonfatal, nodisplay">
        <MvCAPTURE VARIABLE = "l.response">
            <MvCALL ACTION             = "{ g.full_request }"
                    METHOD             = "RAW"
                    FIELDS            = "l.request_body"
                    HEADERS            = "{ g.headers }"
                    CONTENT-TYPE    = "application/json">
                <MvEVAL EXPR = "{ s.callvalue }">
            </MvCALL>
        </MvCAPTURE>
        <MIVA MvCALL_Error = "fatal, display">
    
    
        <MvCOMMENT>If Error, handle</MvCOMMENT>
        <MvIF EXPR = "{ g.MvCALL_Error }">
            <MvFUNCTIONRETURN VALUE = "{ [ g.Module_Library_Utilities ].Error( 'MER-URL-TASK-2', 'Failed To Update: ' $ MvCALL_Error ) }">
        </MvIF>

    Brennan Heyde
    VP Product
    Miva, Inc.
    [email protected]
    https://www.miva.com

    Comment


      #3
      Might consider using mvcapture to create the l.body variable and the fields parameter should not use the expression brackets (aka: fields="variable".
      Bruce Golub
      Phosphor Media - "Your Success is our Business"

      Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
      phosphormedia.com

      Comment


        #4
        I have done a number of SOAP calls in the past,.
        I would remove the "?" from the fields and use something like NA to start testing. Narrow everything down to as plain as you can get it. Here is an example of code I used a number of years ago..... This should help.

        Code:
        <MvAssign name="soap3" value="{ '<?xml version="1.0" encoding="utf-8"?>
        <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
           <SOAP-ENV:Header>
              <RequesterCredentials xmlns="urn:ebay:api:XXXXX" SOAP-ENV:mustUnderstand="1">
                 <Credentials xmlns="urn:ebay:apis:eBLBaseComponents">
                    <Username>' $ golpp.d.user1 $ '</Username>
                    <Password>' $ golpp.d.user2 $ '</Password>
                    <Subject/>
                 </Credentials>
              </RequesterCredentials>
           </SOAP-ENV:Header>
           <SOAP-ENV:Body>
              <SetExpressCheckoutReq xmlns="urn:ebay:api:PayPalAPI">
                 <SetExpressCheckoutRequest xsi:type="ns:SetExpressCheckoutRequestType">
                    <Version xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="xsd:string">1.0</Version>
                    <SetExpressCheckoutRequestDetails xmlns="urn:ebay:apis:eBLBaseComponents">
                       <Token>' $ g.golpptoken $ '</Token>
                       <OrderTotal xmlns="urn:ebay:apis:eBLBaseComponents" currencyID="USD" xsi:type="cc:BasicAmountType">' $ l.goltotal $ '</OrderTotal>
                       <ReturnURL xsi:type="xsd:string">' $ RETURNURL $ '</ReturnURL>
                       <CancelURL xsi:type="xsd:string">' $ CANCELURL $ '</CancelURL>
                    </SetExpressCheckoutRequestDetails>
                 </SetExpressCheckoutRequest>
              </SetExpressCheckoutReq>
           </SOAP-ENV:Body>
        </SOAP-ENV:Envelope>' }">
        
        <MvASSIGN NAME="crlf" VALUE="{asciichar(13) $ asciichar(10)}">
        
        <MvCALL ACTION = "{ golpp.d.url }" CERTFILE = "{ l.directory $ 'xxxxxcert' }"  CERTTYPE = "PEM" METHOD = "XML" FIELDS = "soap3">
        
        <MvEval expr="{ call value }">
        
        </MvCall>
        William Gilligan - Orange Marmalade, Inc.
        www.OrangeMarmaladeinc.com

        Comment

        Working...
        X