Aloita uusi aihe
A

Anonymous

Onko rajapinnanssa url-parametreille määritelty maksimipituus?

20-09-2017 3:40 pm tekijä Anonymous

Hei,

Koitan noutaa rajapinnasta ostolaskuja massanoutona getpurchasinvoice.nv resurssilla, käyttäen NetvisorKeyList parametriä. Url on tällöin muotoa:

https://integration.netvisori.fi/getpurchaseinvoice.nv?NetvsiorKeyList=123,1234,12345...........

Kun paremetrilistan (NetvsiorKeyList=123,1234,12345...........) merkkien lukumäärä ylittää 2048 merkkiä rajapinta vastaa näin:

<!DOCTYPE html><html><head><title>The length of the query string for this request exceeds the configured maxQueryStringLength value.</title><meta name="viewport" content="width=device-width" /><style>body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}  p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; } @media screen and (max-width: 639px) { pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; } } @media screen and (max-width: 479px) { pre { width: 280px; } }</style></head><body bgcolor="white"><span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1><h2><i>The length of the query string for this request exceeds the configured maxQueryStringLength value.</i></h2></span><font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "><b> Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.<br><br><b> Exception Details: </b>System.Web.HttpException: The length of the query string for this request exceeds the configured maxQueryStringLength value.<br><br><b>Source Error:</b><br><br><table width=100% bgcolor="#ffffcc"><tr><td><code>An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</code></td></tr></table><br><b>Stack Trace:</b><br><br><table width=100% bgcolor="#ffffcc"><tr><td><code><pre>[HttpException (0x80004005): The length of the query string for this request exceeds the configured maxQueryStringLength value.] System.Web.HttpRequest.ValidateInputIfRequiredByConfig() +12353445 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +288</pre></code></td></tr></table><br><hr width=100% size=1 color=silver><b>Version Information:</b> Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34274</font></body></html><!--  [HttpException]: The length of the query string for this request exceeds the configured maxQueryStringLength value. at System.Web.HttpRequest.ValidateInputIfRequiredByConfig() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) --><!--  This error page might contain sensitive information because ASP.NET is configured to show verbose error messages using &lt;customErrors mode="Off"/&gt;. Consider using &lt;customErrors mode="On"/&gt; or &lt;customErrors mode="RemoteOnly"/&gt; in production environments.-->

Käytännössä siis: [HttpException (0x80004005): The length of the query string for this request exceeds the configured maxQueryStringLength value.]

Ongelma toistuu eri verkoissa ja eri clienteillä tehtynä.

Olen aiemmin kiertänyt tämän ongelman laskemalla kerralla haettavien laskujen (tai muiden massanoutojen) lukumäärää noin 200-250 kappaleen paikkeille. Rajapintadokumentaatio sallii kuitenkin 500 kappaleen noudon kerralla, ja nyt olisi mukava puolittaa näiden noutojen lukumäärä Smiley Happy.

- Teemu


Tapio Naumanen

21-09-2017 11:48 am tekijä Tapio Naumanen

Moi Teemu,

Omien testien perusteella raja vaikuttaisi olevan 2115 merkkiä mitä otetaan vastaan.

Pitää vielä tutkia tarkemmin tämän logiikka.

A

Anonymous

21-09-2017 5:38 pm tekijä Anonymous

Moi,

Hyvä että pystyit toistamaan ongelman! En ole varma mitä kaikkia URI:n merkkejä tuohon merkkimäärään tulee ottaa huomioon (rajoite voi olla URI:n tai parametrien pituuden suhteen).

- Teemu

Tapio Naumanen

25-09-2017 9:50 am tekijä Tapio Naumanen

Omista testailuista kävi ilmi, että koko URI lasketaan eli ei pelkkää resurssia ja sen parametreja.

Sain varmistuksen asialle, että tämä on tarkoituksella asetettu raja. Myös palvelun (webbilittymä) puolella on sama rajoitus joka on tullut aina aika-ajoin vastaan.

Asiasta juttua: What is the maximum length of a URL in different browsers? - Stack Overflow

Loogista rajoittaa pituus 2000 merkkiin, niin teoriassa ongelmia ei pitäisi syntyä.

Kirjaudu tai Rekisteröidy lähettääksesi kommentin