How do I invoke a MobileFirst Platform Adapter using PUT?

227 views Asked by At

This is similar to the question asked here, but that question was not exactly answered to what the problem is.

Customer.xml

<?xml version="1.0" encoding="UTF-8"?>
<wl:adapter name="Customer"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:wl="http://www.ibm.com/mfp/integration"
    xmlns:http="http://www.ibm.com/mfp/integration/http">

    <displayName>Customer</displayName>
    <description>Customer</description>
    <connectivity>
        <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
            <protocol>https</protocol>
            <domain>kenatibm.cloudant.com</domain>
            <port>443</port>
        </connectionPolicy>
    </connectivity>

    <procedure name="addCustomer"> </procedure>

</wl:adapter>

Customer-impl.js

function addCustomer(param1) {

    var input = {
        method : 'PUT',
        returnedContentType : 'json',
        path : 'userInputRequired',
        body : {
            contentType: 'application/json',
            content : param1
        }
    };

    return WL.Server.invokeHttp(input);
}

The issue is that even though I have defined the method as a PUT, when testing using File Run As | Call MobileFirst Adapter the user interface only displays a GET method, there is no option for PUT.

So is the answer that the GET will actually do a PUT or is this a bug or is there a configuration parameter that I am missing?

enter image description here

2

There are 2 answers

2
Andrew Ferrier On BEST ANSWER

I think you are confusing how you invoke/test the adapter, with what verb it uses on the back-end system it is calling. You are testing/invoking it using GET, but the adapter is then calling your backend system - http://kenatibm.cloudant.com/backendsystem - using PUT.

This is broadly the same explanation as Dave gave in your previous question.

0
Kyle Woodward On

In short, the answer is that the GET will actually do a PUT.

Parameters are passed to the adapter in a GET request and then the adapter constructs a PUT request to perform the actual procedure. In your code, you can see how the 'param1' is passed by the wizard to the function and then it is set to as the 'content' of the PUT request. It's definitely a little confusing.