wso2在多部分/表单数据POST中缺少边界
我正在尝试实现这个场景: wso2Proxy将POST发送到joao.php php获取id值并返回它 如果我从浏览器中调用joao.php,并且表单中有一个名为id的字段,它就会工作。如果我在WSO2代理中也这样做,我会在multipart/form data POST中得到php错误Missing boundary 我使用TCPMon分析调用,WSO2发送内容类型:多部分/表单数据,但没有边界 有人能给我指出正确的方向吗 以下是两个电话: 来自浏览器:wso2在多部分/表单数据POST中缺少边界,wso2,Wso2,我正在尝试实现这个场景: wso2Proxy将POST发送到joao.php php获取id值并返回它 如果我从浏览器中调用joao.php,并且表单中有一个名为id的字段,它就会工作。如果我在WSO2代理中也这样做,我会在multipart/form data POST中得到php错误Missing boundary 我使用TCPMon分析调用,WSO2发送内容类型:多部分/表单数据,但没有边界 有人能给我指出正确的方向吗 以下是两个电话: 来自浏览器: POST /joao.php HTTP
POST /joao.php HTTP/1.1
Host: localhost:7590
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Content-Type: multipart/form-data; boundary=----WebKitFormBoundarytcskUke6yP5MNOzt
Origin: http://localhost:7590
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8
Referer: http://localhost:7590/joao.php
Upgrade-Insecure-Requests: 1
DNT: 1
Content-Length: 135
Connection: keep-alive
------WebKitFormBoundarytcskUke6yP5MNOzt
Content-Disposition: form-data; name="id"
sd
------WebKitFormBoundarytcskUke6yP5MNOzt--
POST /joao.php HTTP/1.1
Content-Type: multipart/form-data
Content-Length: 264
Host: localhost:7590
Connection: Keep-Alive
User-Agent: Synapse-PT-HttpComponents-NIO
--MIMEBoundary_4e039051f0592881a6551113d958f38436c2e8eef5b85bba
Content-Disposition: form-data; name="id"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
teste123
--MIMEBoundary_4e039051f0592881a6551113d958f38436c2e8eef5b85bba--
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="testeSendFile"
transports="http https"
startOnLoad="true">
<description/>
<target>
<inSequence>
<payloadFactory media-type="xml">
<format>
<params xmlns="">
<id>teste123</id>
</params>
</format>
<args/>
</payloadFactory>
<property name="messageType" value="multipart/form-data" scope="axis2"/>
<property name="DISABLE_CHUNKING"
value="true"
scope="axis2"
type="STRING"/>
<log level="full"/>
<send>
<endpoint>
<http method="POST" uri-template="http://localhost:7590/joao.php"/>
</endpoint>
</send>
<log level="full"/>
</inSequence>
</target>
</proxy>
来自WSO2代理:
POST /joao.php HTTP/1.1
Host: localhost:7590
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Content-Type: multipart/form-data; boundary=----WebKitFormBoundarytcskUke6yP5MNOzt
Origin: http://localhost:7590
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8
Referer: http://localhost:7590/joao.php
Upgrade-Insecure-Requests: 1
DNT: 1
Content-Length: 135
Connection: keep-alive
------WebKitFormBoundarytcskUke6yP5MNOzt
Content-Disposition: form-data; name="id"
sd
------WebKitFormBoundarytcskUke6yP5MNOzt--
POST /joao.php HTTP/1.1
Content-Type: multipart/form-data
Content-Length: 264
Host: localhost:7590
Connection: Keep-Alive
User-Agent: Synapse-PT-HttpComponents-NIO
--MIMEBoundary_4e039051f0592881a6551113d958f38436c2e8eef5b85bba
Content-Disposition: form-data; name="id"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
teste123
--MIMEBoundary_4e039051f0592881a6551113d958f38436c2e8eef5b85bba--
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="testeSendFile"
transports="http https"
startOnLoad="true">
<description/>
<target>
<inSequence>
<payloadFactory media-type="xml">
<format>
<params xmlns="">
<id>teste123</id>
</params>
</format>
<args/>
</payloadFactory>
<property name="messageType" value="multipart/form-data" scope="axis2"/>
<property name="DISABLE_CHUNKING"
value="true"
scope="axis2"
type="STRING"/>
<log level="full"/>
<send>
<endpoint>
<http method="POST" uri-template="http://localhost:7590/joao.php"/>
</endpoint>
</send>
<log level="full"/>
</inSequence>
</target>
</proxy>
我对axis2.xml有以下评论部分:
<!--messageFormatter contentType="multipart/form-data"
class="org.wso2.carbon.relay.ExpandingMessageFormatter"/-->
<!--messageBuilder contentType="multipart/form-data"
class="org.wso2.carbon.relay.BinaryRelayBuilder"/-->
这是因为如果我启用它们,那么内容将作为XML而不是多部分/数据发布
因此,这些是为多部分/数据启用的构建器和格式化程序:
<messageFormatter class="org.apache.axis2.transport.http.MultipartFormDataFormatter" contentType="multipart/form-data"/>
<messageBuilder class="org.apache.axis2.builder.MultipartFormDataBuilder" contentType="multipart/form-data"/>
以下是我正在使用的代理配置:
POST /joao.php HTTP/1.1
Host: localhost:7590
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Content-Type: multipart/form-data; boundary=----WebKitFormBoundarytcskUke6yP5MNOzt
Origin: http://localhost:7590
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8
Referer: http://localhost:7590/joao.php
Upgrade-Insecure-Requests: 1
DNT: 1
Content-Length: 135
Connection: keep-alive
------WebKitFormBoundarytcskUke6yP5MNOzt
Content-Disposition: form-data; name="id"
sd
------WebKitFormBoundarytcskUke6yP5MNOzt--
POST /joao.php HTTP/1.1
Content-Type: multipart/form-data
Content-Length: 264
Host: localhost:7590
Connection: Keep-Alive
User-Agent: Synapse-PT-HttpComponents-NIO
--MIMEBoundary_4e039051f0592881a6551113d958f38436c2e8eef5b85bba
Content-Disposition: form-data; name="id"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
teste123
--MIMEBoundary_4e039051f0592881a6551113d958f38436c2e8eef5b85bba--
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="testeSendFile"
transports="http https"
startOnLoad="true">
<description/>
<target>
<inSequence>
<payloadFactory media-type="xml">
<format>
<params xmlns="">
<id>teste123</id>
</params>
</format>
<args/>
</payloadFactory>
<property name="messageType" value="multipart/form-data" scope="axis2"/>
<property name="DISABLE_CHUNKING"
value="true"
scope="axis2"
type="STRING"/>
<log level="full"/>
<send>
<endpoint>
<http method="POST" uri-template="http://localhost:7590/joao.php"/>
</endpoint>
</send>
<log level="full"/>
</inSequence>
</target>
</proxy>
测试123
如果只将文本值作为表单数据发送,则可以使用应用程序/x-www-form-urlencoded
而不是表单数据
请参见这是一个很好的例子。将在下一版本中修复。通过将代理服务更改为以下内容,我能够解决此问题
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="testeSendFile"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="http,https">
<target>
<outSequence>
<property name="OUT_ONLY" value="true"/>
<send/>
</outSequence>
<endpoint>
<address uri="http://localhost:8080/upload"/>
</endpoint>
</target>
<description/>
</proxy>
这是示例请求
您的ESB版本是什么?发布您的synapse configuration.WSO2 ESB 6.1.1。我已编辑以添加axis2.xml。ThxPost your synapse configurationand哪个messageFormatter和messageBuilder用于“多部分/表单数据”?添加了代理服务器,但在我成功发送文本数据后,我想发送一个文件。目标是发送文件和文本数据,因此我需要使用multipart/form-data。这个错误修复了吗?这将在即将发布的APIM 2.2.0版本中修复。计划在3月中旬。在ESB中是否会修复相同的问题?我在ESB中尝试通过代理服务传递maltipart/form数据时遇到了这个错误。我正在使用服务器的5.0.0版本。有关于ESB的消息吗?哪个版本是固定的?