用于测试套接字通信的Mina / Jetty设置的HTTP / 1.1 400错误请求

时间:2017-10-16 07:24:43

标签: java spring sockets jetty mina

我在Spring中定义了这样的码头服务器:

该应用程序作为由Tanuki Java Service包装器包装的服务运行。 所以从本质上讲,它只是在侦听来自套接字的请求时运行。

{
"status": "success",
"data": {
    "messages": [],
    "result": {
        "clinicCode": "Medics",
        "firstName": "Charles",
        "lastName": "Sanders",
        "officeId": 0,
        "id": 7811,
        "startDate": 1508139082929,
        "timeZoneId": 0,
        "userDetailId": 6,
        "userName": "charles",
        "jobTitle": {
            "id": 1,
            "text": "Doctor",
            "count": 1
        },
        "isSuperUser": false,
        "clientId": 10,
        "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjbGluaWNDb2RlIjoiTWVkaWNzIiwiZW1haWwiOm51bGwsImVuZERhdGUiOm51bGwsImZpcnN0TmFtZSI6IkNoYXJsZXMiLCJsYXN0TmFtZSI6IlNhbmRlcnMiLCJvZmZpY2VJZCI6MCwiaWQiOjc4MTEsInNwZWNpYWx0eUlkIjpudWxsLCJzdGFydERhdGUiOjAsInRpbWVab25lSWQiOjAsInVzZXJEZXRhaWxJZCI6NiwidXNlck5hbWUiOiJjaGFybGVzIiwib2ZmaWNlIjpudWxsLCJzcGVjaWFsdHkiOm51bGwsInRpbWVab25lIjpudWxsLCJ1c2VyRGV0YWlsIjpudWxsLCJwYXJhbWV0ZXJzIjpudWxsLCJqb2JUaXRsZSI6bnVsbCwiaXNTdXBlclVzZXIiOmZhbHNlLCJjbGllbnRJZCI6MTAsImNvZGUiOm51bGwsInRva2VuIjpudWxsLCJlbXBsb3llZUlkIjoxNCwicHJvdmlkZXJJZCI6bnVsbCwiaXNBY3RpdmUiOmZhbHNlLCJpc0xvY2tlZCI6ZmFsc2UsImxhc3RQYXNzd29yZENoYW5nZWQiOjAsImxvY2tlZENvZGVJZCI6bnVsbCwibG9ja2VkRGF0ZVRpbWUiOm51bGwsInBhc3N3b3JkIjpudWxsLCJwYXRpZW50SWQiOm51bGwsInByZWZMYW5nSWQiOm51bGwsInNlc3Npb25JZCI6NzgxMSwiY3JlYXRlZEJ5IjpudWxsLCJlbXBsb3llZSI6bnVsbCwibGFzdE1vZGlmaWVkQnkiOm51bGwsImxvY2tlZENvZGUiOm51bGwsInBhdGllbnQiOm51bGwsInByZWZMYW5nIjpudWxsLCJhcHBsaWNhdGlvbk5hbWUiOm51bGwsIm1hY2hpbmVJZCI6bnVsbCwibGFuZ0lkIjpudWxsLCJjb3VudHJ5Q29kZSI6IlVTIn0.Zd0TwwjP_HjzfgQzfS_-QIAXQ1F8TNTxFMSpve5VRWo",
        "employeeId": 14,
        "isActive": false,
        "isLocked": false,
        "lastPasswordChanged": 0,
        "sessionId": 0
    }
}
}

并使用Mina作为终点

<bean id="jetty" class="org.eclipse.jetty.server.Server" init-method="start">
    <constructor-arg name="port" value="${Port}" />
</bean>

然后在system.xml中,

<bean id="minaFactory" class="org.apache.camel.component.mina2.Mina2Component">
    <constructor-arg index="0" ref="camel"></constructor-arg>
</bean>

<bean id="minaEndpoint" factory-bean="minaFactory" factory-method="createEndpoint">
    <constructor-arg index="0" ref="minaConfig1"></constructor-arg>
</bean>

现在,我使用了套接字测试 - https://sourceforge.net/projects/sockettest/?source=typ_redirect

我可以连接到主机和端口,但在发送请求时我一直收到错误:

S:{&#34;行动&#34;:&#34;测试&#34;,&#34;工作&#34;:&#34; abc&#34;} HTTP / 1.1 400错误请求 内容长度:0 连接:关闭 服务器:Jetty(7.2.0.v20101020)

Socket Test

1 个答案:

答案 0 :(得分:0)

我删除了jetty.xml并且它有效。