Clarity Service Management

Expand all | Collapse all

How to create requests in Service Catalog via webservice?

Jump to Best Answer
  • 1.  How to create requests in Service Catalog via webservice?

    Posted 03-02-2018 01:27 PM

    Hi guys,

    I'm trying to develop a integration that create new service requests in Service Catalog from a third party app, using the following methods to perform the needed actions:

     

    addRequestWithForm - to insert the new request
    getRequestItems - to recover the subscriptions detail ids for each form attached
    saveForm - to fill the form fields.
    submitRequest - to submit the request

     

    All offers uses approval process 2 (approval process driven by workflow) , that fire a PAM workflow to validate approval rules after request submission.

    When i try to add a request with offer 10243, the method return a error message, but a new request is created and no items are added to it

     

    Request:

    <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.soap.usm.ca.com">
    <soapenv:Header/>
    <soapenv:Body>
    <ser:addRequestWithForm soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <sessionID xsi:type="xsd:string">6916ce25-fa61-4d5a-953d-1920343b9d72</sessionID>
    <requestData xsi:type="xsd:string">name:Nova solicitacao via WS!priority:3!status:100!req_by_user_id:usr_caitsm!req_for_user_id:usr_caitsm</requestData>
    <requestValuesData xsi:type="xsd:string"></requestValuesData>
    <requestValuesDataType xsi:type="xsd:string"></requestValuesDataType>
    <addedOfferings xsi:type="xsd:string"></addedOfferings>
    <addedItems xsi:type="xsd:string">offering_id:10243!rate_item_id:10147!item_id:12985</addedItems>
    <formValuesData xsi:type="xsd:string">offering_id:10243</formValuesData>
    </ser:addRequestWithForm>
    </soapenv:Body>
    </soapenv:Envelope>

     

    Response:

    <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.generalException</faultcode>
    <faultstring>Exception occurred in get Request Approval List.</faultstring>
    <detail>
    <ns1:exceptionName xmlns:ns1="http://xml.apache.org/axis/">com.ca.usm.soap.axisInterfaces.WebServiceException</ns1:exceptionName>
    <ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">SERVERNAME</ns2:hostname>
    </detail>
    </soapenv:Fault>
    </soapenv:Body>
    </soapenv:Envelope>

     

    The new request seems like this:

    This form need to be added (created via WS using another offering_id):

     



  • 2.  Re: How to create requests in Service Catalog via webservice?

    Posted 03-02-2018 05:59 PM

    Hey Albino,

     

    I used the following to test the addRequestWithForm method via soapUI:

     

    1) The requestData is essentially the data for the 'General Information' form. I used the following:

     

    name:soapUI Test!req_by_user_id:spadmin!req_for_user_id:spadmin

     

    2) The requestValuesData is essentially the data for the 'Request Information' form. I used the following:

     

    comments:soapUI comment!gl_code:soapUI gl!project:soapUI project

     

    3) The requestValuesDataType is only necessary if you are passing data in step 2) above that you need to be stored as a data type other than string. I left this blank using the above requestValuesData.

    4) The addedOfferings parameter takes the offering_id for each offering you would like to add to the request. I just added one offering using the following:

     

    offering_id:10176

     

    5) The addedItems is only necessary if you don't have a default option selected for the offering or if you need to specify something like cost/quantity. I left this blank as my offering has a default option selected.

    6) The formValuesData is a list of the offering form data which is separated by vertical bars (|). I used the following to define 2 text fields:

     

    offering_id:10176|rate_plan_id:10184|item_id:21859|txtf_10:txtf_10|txtf_11:txtf_11

     

    Note 1: You can get the rate_plan_id (service option group id) from Catalog > Option Groups > <select your option group> > Id (under the 'Details' tab)
    Note 2: I used the following to get the item_id of the form element (21859):

     

    select item_id from usm_rate_definition where rate_plan_id=10184 and item_type=14 and status=1


    So the following is the full soap body I used to test in soapUI:

     

    <soapenv:Body> 
      <ser:addRequestWithForm soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
        <sessionID xsi:type="xsd:string">c300b805-ecb0-4960-8f39-2f7a4c49f46e</sessionID>
        <requestData xsi:type="xsd:string">name:soapUI Test!req_by_user_id:spadmin!req_for_user_id:spadmin</requestData>
        <requestValuesData xsi:type="xsd:string">comments:soapUI comment!gl_code:soapUI gl!project:soapUI project</requestValuesData>
        <requestValuesDataType xsi:type="xsd:string"></requestValuesDataType>
        <addedOfferings xsi:type="xsd:string">offering_id:10176</addedOfferings>
        <addedItems xsi:type="xsd:string"></addedItems>
        <formValuesData xsi:type="xsd:string">offering_id:10176|rate_plan_id:10184|item_id:21859|txtf_10:txtf_10|txtf_11:txtf_11</formValuesData>
      </ser:addRequestWithForm>
    </soapenv:Body>

     

    Hope this helps!

     

    Thanks,
    Jason



  • 3.  Re: How to create requests in Service Catalog via webservice?

    Posted 07-10-2018 02:56 PM

    Hi Jason,

     

    My service option group has 4 items and each item contais some fields to user fill. On this case, how i need to do the request to webservice?

     

    The tag formValuesData will look like this?
    <formValuesData xsi:type="xsd:string">offering_id:10230|rate_plan_id:10147|item_id:13181|field_1:text|item_id:13182|field_2:text|field_3:text</formValuesData>

     

    Another question, how can i identify the name of the fields embedded in the item_id?

     

     

    Thanks,

    Albino



  • 4.  Re: How to create requests in Service Catalog via webservice?
    Best Answer

    Posted 03-05-2018 02:00 AM

    Good Morning to you.

    For an existing offering/sog/service-option-with-form, please check the below possible WSDL.
    Please note, these are examples and need to be enhanced, according to your local settings of course.

    SOAPUI: http://HOST:PORT/usm/services/RequestService?wsdl
    Login_ID:
    8dc7b70b-d514-4fe8-aa8c-cd316ac8e1b6

    1) First we create an empty request
    Client:
    <requestData xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">name: ABAKUS: REQ0030198 - RITM0042146!created_date:2017-07-31 04:25:56!desired_date:!priority:4!req_by_user_id:H715000!req_for_user_id:H715000!comments:ServiceNow SYS_ID:CAT001371</requestData>
    <requestValuesData xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">authorization_number:RITM0042146!project:CAT001371!gl_code:88888!cost_center:(spezifiziert in der Service auftrag Form)!ship_to_address1:N/A!ship_to_city:N/A!ship_to_state:N/A!ship_to_postal:N/A!ship_to_country:N/A</requestValuesData>

    Local amelo01-I1660:
    <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.soap.usm.ca.com">
    <soapenv:Header/>
    <soapenv:Body>
    <ser:saveRequest soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <sessionID xsi:type="xsd:string">8dc7b70b-d514-4fe8-aa8c-cd316ac8e1b6</sessionID>
    <requestData xsi:type="xsd:string">name: ABAKUS: REQ0030198 - RITM0042146|created_date:2017-07-31 04:25:56|desired_date:|priority:4|req_by_user_id:spadmin|req_for_user_id:amelo01|comments:ServiceNow SYS_ID:CAT001371</requestData>
    <requestValuesData xsi:type="xsd:string">authorization_number:RITM0042146|project:CAT001371|gl_code:88888|cost_center:(spezifiziert in der Service auftrag Form)|ship_to_address1:N/A|ship_to_city:N/A|ship_to_state:N/A|ship_to_postal:N/A|ship_to_country:N/A</requestValuesData>
    <requestValuesDataType xsi:type="xsd:string"></requestValuesDataType>
    <addedOfferings xsi:type="xsd:string"></addedOfferings>
    <removedOfferings xsi:type="xsd:string"></removedOfferings>
    <addedItems xsi:type="xsd:string"></addedItems>
    </ser:saveRequest>
    </soapenv:Body>
    </soapenv:Envelope>

    Result: <requestID xsi:type="xsd:int">10167</requestID>

    2) Then we save the service into the request
    SELECT o.offering_id, o.offering_name,
    rp.rate_plan_id, rp.status,rp.date_available, rp.is_inherited, rp.total_rows, rp.total_cols,rp.domain,rp.sort_order_no,rp.rate_plan_name,rp.description,
    ori.id as iid, ori.layout as layout
    FROM usm_offering o, usm_rate_plan rp,usm_offering_rplan_inclusion ori
    WHERE o.offering_name = 'SAP Lieferant'
    AND ori.parent_id=o.offering_id
    AND rp.rate_plan_id=ori.child_id
    AND rp.status in (1,6)
    Result: 10248 SAP Lieferant 10171 ~ Bestellung von Services

    <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.soap.usm.ca.com">
    <soapenv:Header/>
    <soapenv:Body>
    <ser:saveRequestItems soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <sessionID xsi:type="xsd:string">8dc7b70b-d514-4fe8-aa8c-cd316ac8e1b6</sessionID>
    <requestID xsi:type="xsd:int">10167</requestID>
    <addedOfferings xsi:type="xsd:string">offering_id:10248</addedOfferings>
    <removedOfferings xsi:type="xsd:string"></removedOfferings>
    <addedItems xsi:type="xsd:string"></addedItems>
    </ser:saveRequestItems>
    </soapenv:Body>
    </soapenv:Envelope>

    3) After that, we fill out the attached form
    select id from usm_subscription_detail where request_id=10167 and subscription_type=5
    Result: 10703

    <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.soap.usm.ca.com">
    <soapenv:Header/>
    <soapenv:Body>
    <ser:saveRequestForm soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <sessionID xsi:type="xsd:string">8dc7b70b-d514-4fe8-aa8c-cd316ac8e1b6</sessionID>
    <subscriptionDetailID xsi:type="xsd:int">10703</subscriptionDetailID>
    <formValuesData xsi:type="xsd:string">pri_phone_number:9932431|email_address:amelo01@maildomain.com|first_name:Louis|last_name:Amelsfort|userid:amelo01</formValuesData>
    </ser:saveRequestForm>
    </soapenv:Body>
    </soapenv:Envelope>
    Result: NO error.

    With:
    <formValuesData xsi:type="xsd:string">pri_phone_number:9932431|email_address:amelo01@maildomain.com|first_name:Louis|last_name:Amelsfort|userid:amelo01</formValuesData>
    It works okay.

    I then added "|FromDate:" and get the below error:
    <formValuesData xsi:type="xsd:string">pri_phone_number:9932431|email_address:amelo01@maildomain.com|first_name:Louis|last_name:Amelsfort|userid:amelo01|FromDate:</formValuesData>
    Result: Error in view.log:
    2017/08/04 18.15.41.640 DEBUG [http-bio-8080-exec-11] [RequestServiceImpl] propsFormData :{userid=H715000, first_name=Rüdiger, lokation_haus=CT01, befrBisPflicht=, email_address=Ruediger.Kinert@enviam.de, hiddenFields=;hiddenFields;FromDate;ToDate;ServiceCode;befrBisPflicht;befrVonPflicht;Beschreibung_pflicht;PC;, FromDate=, lokation_lokation=Chemnitz - Chemnitztalstr. 13 (enviaM), ServiceCode=SN(CAT001371);acc#, Account=0b4cd065f6cdba4f9254cbe52421aaba|H715000, lokation_raum=302a, befrVonPflicht=, befrBis=, ToDate=, last_name=Kinert, pri_phone_number=9932431, Beschreibung= Anfragetyp: Vorhandener Nutzer zuordnen., befrVon=}
    2017/08/04 18.15.41.641 ERROR [http-bio-8080-exec-11] [RequestServiceImpl] SOAPREQ010
    java.lang.NullPointerException

    <formValuesData xsi:type="xsd:string">pri_phone_number:9932431|email_address:amelo01@maildomain.com|first_name:Louis|last_name:Amelsfort|userid:amelo01|FromDate:08/04/2017 0:0:0</formValuesData>
    "|FromDate:08/04/2017 0:0:0", all runs okay again.

    Kind regards, Louis van Amelsfort.