ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

IWS and REGEX

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

  • IWS and REGEX

    My incoming web service has one input. A part number that can be up to 30 characters. The part number is alphanumeric and can have dashes, periods, or embedded spaces. When I'm deploying my IWS service I have this defined as my URI path template:

    PHP Code:
    /{mpart:([a-zA-Z0-9-\.\s]+)} 
    When I attempt to run the web service passing a part number with an imbedded blank in it, I get a "403 Forbidden" error. Any part with no imbedded blanks works fine.

    In my research I thought the "\s" would take care of that. I also tried "␣" and just a single space. Nothing else seems to work.

    This is my SoapUI screen for a part (hp 1750) with a space and my error:

    Click image for larger version

Name:	Space URI.PNG
Views:	133
Size:	42.5 KB
ID:	157126

    And without a space (20275) which works perfectly:

    Click image for larger version

Name:	Non-Space URI.PNG
Views:	100
Size:	44.9 KB
ID:	157127

    Parts with dashes and periods work great. Just embedded blanks are giving me problems.

    Any help for this complete novice?

    Thanks!!!

  • #2
    Spaces are not usdually valid in URLs and should be replaced with either %20 or + depending on the type of encoding the endpoint expects
    So you might want to try "/web/services/iteminq/hp%201750" or "/web/services/iteminq/hp+1750"

    The Javascript function encodeURIComponent() is used for sanitising values to make them URL safe, and will use %20
    I forget the equivalent in Java, and it uses +

    Most decent endpoint softwares will accept either, I don't know if that's true for the IBM i

    Comment


    • #3
      Thanks! Got it working now!!!!

      Comment


      • #4
        Glad to hear it!

        Comment

        Working...
        X