Layer7 API Management

  • 1.  request.mainpart is null

    Posted Sep 12, 2016 10:52 AM

    Hello

     

    I am trying to fix a problem with a webservice that is supposed to work with a multipart message. For some reason only one of our clients is having this problem, for everyone else it is working correctly.

     

    By adding the debugger to the service, we have been able to see that the API Gateway is unable to extract any data from the request and populate request.mainpart, even though we are sure that there is data there. This in turn causes sebsequent assertions to fail.

     

    The Content-Type for this request is

     

    "multipart/related; type="text/xml"; boundary="...""

     

    Having seen a question here about response.mainpart being null, we have tried the approach suggeested in that answer, and have added the following variables to the debugger:

     

    • request.parts.0.body
    • request.parts.0.mainpart
    • request.parts[0]

     

    With these variables in the debugger, we have obtained the following values:

    request.mainpart = null
    request.parts.0.body = null
    request.parts.0.mainpart = null
    request.parts[0] = {j} "com.l7tech.common.mime.j@1d3937c6"

    the class 'j' is obviously an obfuscated Java class, but we are unsure what to do with it.

     

    Any help or pointers would be greatly appreciated.

     

    Kind regards

     

    Richard Thomas



  • 2.  Re: request.mainpart is null
    Best Answer

    Broadcom Employee
    Posted Sep 12, 2016 04:48 PM

    Richard,

     

    The issue that you may be encountering is in how the boundary in the message is constructed not in the Content-type header. We included a new system property that can be set in /opt/SecureSpan/Gateway/node/default/etc/conf/system.properties file called com.l7tech.common.mime.allowLaxInitialBareCrOrLf with the value of true. Making this change will require the gateway to be restarted to take effect.

     

    If you can send through the raw message that will help determine if this is the cause.

     

    Sincerely,

     

    Stephen Hughes

    Director, CA Support



  • 3.  Re: request.mainpart is null

    Posted Dec 15, 2016 02:26 PM

    Hi Stephen, what does the setting do? I have an issue that I want to read a Content Security Protection report message of the browser with has a content-type of 'application/csp-report'. On the gateway the request.mainpart is shown empty, but in the request tab it is shown when debugging of the service is enabled. Changing the content-type to application/json (by an other proxy will show the payload). Do I need the same solution you suggested?

     

    Raw message:

     

    POST https://lerarenregister.mso.mhsrijk.nl:8024/csp HTTP/1.1
    Host: lerarenregister.mso.mhsrijk.nl:8024
    Connection: keep-alive
    Content-Length: 570
    Origin: https://lerarenregister.mso.mhsrijk.nl:8024
    User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36
    Content-Type: application/csp-report
    Accept: */*
    Referer: https://lerarenregister.mso.mhsrijk.nl:8024/
    Accept-Encoding: gzip, deflate, br
    Accept-Language: nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4

    {"csp-report":{"document-uri":"https://lerarenregister.mso.mhsrijk.nl:8024/","referrer":"","violated-directive":"style-src 'self' ","effective-directive":"style-src","original-policy":"default-src 'self' ; script-src 'self' 'unsafe-inline' 'unsafe-eval' ; style-src 'self' ; font-src * data: ; img-src * data: ; frame-ancestors 'self' ; child-src 'self' ; upgrade-insecure-requests; block-all-mixed-content; report-uri https://lerarenregister.mso.mhsrijk.nl:8024/csp;","blocked-uri":"inline","line-number":59,"column-number":18,"source-file":"webpack","status-code":0}}



  • 4.  Re: request.mainpart is null

    Broadcom Employee
    Posted Dec 15, 2016 02:52 PM

    Edward,

     

    The above setting is for multi-part messages with attachments not text bases response messages. It sounds more like the gateway does not view your content-type as text so it will attempt to treat it different. Try adding in the cluster wide property contentType.otherTextualTypes with the value of application/csp-report to see if this resolves your issue.

     

    Sincerely,

     

    Stephen Hughes

    Director, CA Support



  • 5.  Re: request.mainpart is null

    Posted Dec 15, 2016 04:10 PM

    Stephen, you are my hero of the month. It solved my issue!

    Thank you!



  • 6.  Re: request.mainpart is null

    Broadcom Employee
    Posted Dec 15, 2016 04:47 PM

    Edward,

     

    Glad I could help out. Have a great day.

     

    Sincerely,

     

    Stephen Hughes

    Director, CA Support



  • 7.  Re: request.mainpart is null

    Posted Oct 22, 2018 10:03 AM

    Great, it helped me partially. I've added the setting in /opt/SecureSpan/Gateway/node/default/etc/conf/system.properties: com.l7tech.common.mime.allowLaxInitialBareCrOrLf=true and

    set the cluster wide property contentType.otherTextualTypes = application/http.

    Now I have in request.mainpart the first part of the request as a string (before it was null). 

     

    My request looks like:

     

    Request URL: http://url/Z_AUFTRAGSUEBERSICHT_SRV/$batch?sap-client=100

    Request Method: POST
    Referrer Policy: no-referrer-when-downgrade
    Accept: multipart/mixed
    Accept-Encoding: gzip, deflate
    Accept-Language: en-US
    Connection: keep-alive
    Content-Length: 733
    Content-Type: multipart/mixed;boundary=batch_e6bf-ce6f-0802
    Cookie: MYSAPSSO2=AjQxMD.....
    DataServiceVersion: 2.0
    MaxDataServiceVersion: 2.0
    sap-cancel-on-close: true
    sap-contextid-accept: header

     

    sap-client: 100


    --batch_e6bf-ce6f-0802
    Content-Type: application/http
    Content-Transfer-Encoding: binary

    GET UEBERSICHTSet/$count?sap-client=100&$filter=Kunnr%20eq%20%270000014036%27 HTTP/1.1
    sap-contextid-accept: header
    Accept: text/plain, */*;q=0.5
    Accept-Language: en-US
    DataServiceVersion: 2.0
    MaxDataServiceVersion: 2.0
    sap-cancel-on-close: true


    --batch_e6bf-ce6f-0802
    Content-Type: application/http
    Content-Transfer-Encoding: binary

    GET UEBERSICHTSet?sap-client=100&$skip=0&$top=100&$filter=Kunnr%20eq%20%270000014036%27 HTTP/1.1
    sap-contextid-accept: header
    Accept: application/json
    Accept-Language: en-US
    DataServiceVersion: 2.0
    MaxDataServiceVersion: 2.0
    sap-cancel-on-close: true


    --batch_e6bf-ce6f-0802--

     

     

    And here is the the first part of the request as a string in the main part, which is shown in the GW:

     

    request.mainpart = {String} "GET UEBERSICHTSet/$count?sap-client=100&$filter=Kunnr%20eq%20%270000014036%27 HTTP/1.1
    sap-contextid-accept: header
    Accept: text/plain, */*;q=0.5
    Accept-Language: en-US
    DataServiceVersion: 2.0
    MaxDataServiceVersion: 2.0
    sap-cancel-on-close: true

    "

     

    My question is how can I get the second part of the request? Means how can I access the "GET UEBERSICHTSet?sap-client=100&$skip=0&$top=100&$filter=Kunnr%20eq%20%270000014036%27 HTTP/1.1" ? 

     

    Another question is if it is this way only to access the single parts in the multipart requests? I need to select each element like "Accept: text/plain' and "GET UEBERSICHTSet?sap-client=100..."  in every part and now I have to parse it from the string. That's why I thought maybe there is a way to get it into an object. It would facilitate the accessing of each element in every part.

     

    best regards,

    Oleks



  • 8.  Re: request.mainpart is null

    Posted Oct 29, 2018 08:58 AM

    I figured this out, the answer is: using request.parts.i.body you can access the attachments, so in my case I get the 2th part using request.parts.2.body. And it is not possible to get the String type to a request object, have to do it manually to extract the data, i.e. split it with assertion or with the JS assertion.



  • 9.  Re: request.mainpart is null

    Posted Jan 10, 2019 11:11 AM

    Hi,
    I am trying to buid a Web Service connector based on "Web Serverices - Layer 7". I have a problem wiht the update event.
    When i update an user in Prv Manager, the user's information does not send into the request to API Gateway.
    The request send is:
    request = {Message}
        contentType = {String} "text/xml; charset=utf-8"
        http.allheadervalues = {Object[]} size = 5
            [0] = {String} "accept:application/json"
            [1] = {String} "authorization:Basic aW1hZG1pbjoxMjM0cXdlcg=="
            [2] = {String} "connection:Keep-Alive"
            [3] = {String} "host:100.126.18.42:8080"
            [4] = {String} "user-agent:Apache-HttpClient/4.2.2 (java 1.5)"
        mainpart = {String} ""

     

    ${request.mainpart} = null
    ${request.http.method} = GET
    ${request.http.parameter.filter} = field eq "userid"
    ${request.http.parameter.attributes} = field1,field2,field3
    ${request.http.uri} = /MyApp/v1/Users

     

    My question is how can i do to send the json mainpart and correct method from Prv Store to CA API Gateway.

     

    Best regards,
    Cristian Garcia.