Nova postagem

Pesquisar

Artigo
· jan 6 2min de leitura

JSON文字からダイナミックオブジェクトを作成する際、エラー #5035: 一般例外 名前 'Premature end of data'エラーが出る

これは InterSystems FAQ サイトの記事です。

POST要求で受信したBodyのJSON文字列を、REST ディスパッチクラス内メソッドでダイナミックオブジェクト(%DyamicObject)に変換する際、以下エラーが発生する場合があります。

{
    "errors": [
        {
            "code": 5035,
            "domain": "%ObjectErrors",
            "error": "エラー #5035: 一般例外 名前 'Premature end of data' コード '12' データ ''",
            "id": "GeneralException",
            "params": [
                "Premature end of data",
                12,
                ""
            ]
        }
    ],
    "summary": "エラー #5035: 一般例外 名前 'Premature end of data' コード '12' データ ''"
}

POST要求時に送付するBodyの中身は、RESTディスパッチクラスの中では %request.Content を使用して操作でき、%request.Content.Read()とした場合、JSON文字列が取り出せます。

%request.Content.Read()の結果(=POST要求で受信したBodyの長さ)が32KBを超える場合、Read()メソッドは先頭32KBまでしか読み取らない制限があるため、すべてのJSON文字列が渡らずに上記エラーが発生します。

メモ:変数%requestは%CSP.Requestクラスのインスタンス

JSON文字からダイナミックオブジェクトに変換する際使用する%FromJSON()メソッドの引数には、JSON文字列かJSON文字列が含まれるストリームを指定することができます。

Read()メソッドは先頭32KBまでしか読み取らない制限があるので、以下の例のようにRead()の結果を渡すのではなく

set bodyjson={}.%FromJSON(%request.Content.Read())

JSON文字を含むストリームを%FromJSON()に渡す以下例の方法を使用することで、32KBを超えるJSON文字列が含まれていたとしても、エラーなくダイナミックオブジェクトに変換できます。

set bodyjson={}.%FromJSON(%request.Content)
Discussão (0)1
Entre ou crie uma conta para continuar
Pergunta
· jan 6

Using the Intersystems ObjectScript plugin, how can I automatically import to the server when I delete the code file locally on my client machine?

I have installed three plugins on VS Code: Intersystems Language Server: v2.3.6, Intersystems ObjectScript: v2.10.5, and Intersystems Server Manager: v3.6.2. I connected to the Caché database and connected a workspace to the InterSystems server. Then I edited the code locally on my client machine.

6 Comments
Discussão (6)3
Entre ou crie uma conta para continuar
Pergunta
· jan 6

Interface Behavior with invalid TLS Cert for 'Server certificate verification'

Hello,

I was just trying to get to the bottom of a TLS config - we have an interface with a TLS config that has had 'Server certificate verification' set to 'On', however the cert file specified either did not exist or contained a cert that was expired.

 

Does anyone know what the behavior is for this typically? I would expect this to not allow traffic on the interface, however this has been working fine for a few years now with an invalid cert specified for 'Server certificate verification' and set to 'On'.

 

Discussão (0)1
Entre ou crie uma conta para continuar
Anúncio
· jan 6

Recapitulação do InterSystems Developer Community, Dezembro 2024

Olá e bem-vindo ao Recapitulação da comunidade de desenvolvedores Dezembro 2024.
Estatísticas gerais
20 novas postages publicadas em Dezembro:
 13 novos artigos
 6 novos anúncios
 1 nova pergunta
1 novos membros ingressaram em Dezembro
1,245 postagens publicadas ao todo
610 membros ingressaram ao todo
Principais publicações
Principais autores do mês
Artigos
#InterSystems IRIS
 
#Outro
 
#Portal de ideias da InterSystems
 
Anúncios
Perguntas
#InterSystems IRIS
 
Dezembro, 2024Month at a GlanceInterSystems Developer Community
Discussão (0)1
Entre ou crie uma conta para continuar
Pergunta
· jan 6

Adapteur UDP ne fonctionne pas

Bonjour

J'essaie de travailler avec l'Adapteur/Connection UDP- et j'ai cette erreur .

ERREUR #5002: Erreur Cache: <WRITE>zSend+5^EnsLib.UDP.Common.1

 Voici la méthode
 

Class TEMPLATE.BO.UDPSend Extends Ens.BusinessOperation
{

Parameter ADAPTER = "EnsLib.UDP.OutboundAdapter";

Property Adapter As EnsLib.UDP.OutboundAdapter;

Method SendData(pInput As Ens.Request, Output pOutput As Ens.Response) As %Status
{
    Try {
        Set status=$$$OK
        Set pOutput=##class(Ens.Response).%New()
        
        Set stream = ##class(%Stream.GlobalCharacter).%New()
        Do stream.Write("This is some text")
        $$$LOGINFO(stream.Read())
        Do stream.Rewind()

        Set status = ..Adapter.SendStream(stream)
    }
    Catch exception {
        Set status=exception.AsStatus()
    }    
    Return status
}

XData MessageMap
{
<MapItems>
<MapItem MessageType="Ens.Request">
<Method>SendData</Method>
</MapItem>
</MapItems>
}

}

J'ai essayé avec ##class(%Net.UDP).%New() et cela fonctionne.

Quelqu'un a t'il une idée de pourquoi cela ne fonctionne pas ou des exemples d'une méthode fonctionnel, s'il vous plaît?

 

Par avance, merci


Corentin

PS : Pour ceux qui ne veulent pas explorer le code pour trouver la ligne où est généré l'erreur :

zSend(pDevice="",pBuffer) public { Set:'($data(pBuffer)#2) pBuffer=""
    Set tStatus = 1
    Try {
        Do pBuffer.Rewind()
        Use pDevice Do pBuffer.OutputToDevice()
        Use pDevice Write !
    }
    Catch eSend {
        Set tStatus = eSend.AsStatus()
    }
    Quit tStatus }
6 Comments
Discussão (6)2
Entre ou crie uma conta para continuar