2016-03-28 10 views
3

私はファイルを受信し、マルチパート/フォームデータ入力としてデモAPIを使用しており、ファイルとノートの内容を表示しています。ここで正しくAPIを実行したサンプルHTMLは次のとおりです。wso2マルチパート/フォームデータ投稿要求のゲートウェイ転送

<html> 
    <body> 
    <FORM action="http://cgi-lib.berkeley.edu/ex/fup.cgi" method="post"> 
     <P>Choose file: <INPUT type="file" name="upfile"> 
     <p>Note: <INPUT type="text" name="note"> 
     <p><INPUT type="submit" value="Send"> 
    </FORM> 
    </body> 
</html> 

今私はWSO2 APIMの出版社で管理APIを作成しようとしています。

enter image description here

は私が追加APIを経由してHTMLのアクションを交換しています::以下は私が満たされたパラメータです

<FORM action="http://ec2-52-48-93-41.eu-west-1.compute.amazonaws.com:8280/test" method="post"> 

しかし、今は、私は私が手HTMLを実行したときAPIから次のエラー:

cgi-lib.pl: Unknown Content-type: application/x-www-form-urlencoded; charset=UTF-8 

はWSO2ゲートウェイは、アプリケーション/ x-www-form-urlencodedでとしてではなくmulipart /フォームデータとして要求を転送しように思えます。私は

<messageFormatter contentType="multipart/form-data" 
     class="org.apache.axis2.transport.http.MultipartFormDataFormatter"/> 
    <messageBuilder contentType="multipart/form-data" 
     class="org.apache.axis2.builder.MultipartFormDataBuilder"/> 

をコメントアウトして、

<messageFormatter contentType="multipart/form-data" 
    class="org.wso2.carbon.relay.ExpandingMessageFormatter"/> 
<messageBuilder contentType="multipart/form-data" 
    class="org.wso2.carbon.relay.BinaryRelayBuilder"/> 

に置き換えることを試み、以下の議論multipart form data file upload using WSO2 API manger ?に基づいて

は、サーバーを再起動しますが、それはどんな影響が発生することはありませんでした。

アイデアをお寄せいただきありがとうございます。

収集したログメッセージの一部。ターゲットAPIは異なりますが、受け取ったものをダンプするmultipart/form-data APIです。

着信要求292

DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> POST /test/1.0.0 HTTP/1.1 {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> Host: ec2-52-48-93-41.eu-west-1.compute.amazonaws.com:8280 {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> Connection: keep-alive {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> Content-Length: 292 {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> Cache-Control: max-age=0 {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> Origin: null {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> Upgrade-Insecure-Requests: 1 {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36 {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryqwBdAwOnlDYeHNNR {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> Accept-Encoding: gzip, deflate {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> Accept-Language: en-US,en;q=0.8,he;q=0.6 {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 >> Cookie: region3_registry_menu=visible; region1_manage_menu=visible; region1_identity_menu=visible; menuPanel=visible; menuPanelType=main; csrftoken=n1g69f3slt1d90qvtaa28rtm1b {org.apache.synapse.transport.http.headers} 

のコンテンツ長と、コンテンツ型マルチパート/フォームデータを持っている発信要求は、コンテンツタイプを持っていない。

当然
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 >> POST /sample2/api/company/upload HTTP/1.1 {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 >> Cookie: region3_registry_menu=visible; region1_manage_menu=visible; region1_identity_menu=visible; menuPanel=visible; menuPanelType=main; csrftoken=n1g69f3slt1d90qvtaa28rtm1b {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 >> Origin: null {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 >> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 >> Cache-Control: max-age=0 {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 >> Upgrade-Insecure-Requests: 1 {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 >> Accept-Encoding: gzip, deflate {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 >> Accept-Language: en-US,en;q=0.8,he;q=0.6 {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 >> Transfer-Encoding: chunked {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 >> Host: localhost:8080 {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 >> Connection: Keep-Alive {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 >> User-Agent: Synapse-PT-HttpComponents-NIO {org.apache.synapse.transport.http.headers} 

、受信応答にはHTTP 415、サポートされていないメディアがあります:

DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 << HTTP/1.1 415 Unsupported Media Type {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 << Server: Apache-Coyote/1.1 {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 << Content-Length: 0 {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 << Date: Mon, 28 Mar 2016 13:53:05 GMT {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 << HTTP/1.1 415 Unsupported Media Type {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 << Access-Control-Allow-Origin: * {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 << Access-Control-Allow-Methods: POST {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 << Access-Control-Allow-Headers: authorization,Access-Control-Allow-Origin,Content-Type {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 << Date: Mon, 28 Mar 2016 13:53:05 GMT {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 << Transfer-Encoding: chunked {org.apache.synapse.transport.http.headers} 
DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 << Connection: keep-alive {org.apache.synapse.transport.http.headers} 

APIの電子シナプス:新しいAPI Managerはclients.Youから浮き袋特定のヘッダがリポジトリ/ confにして、次のプロパティhttp.headers.preserve = Content-Typeのを追加する必要はありませんように、デフォルトで

<?xml version="1.0" encoding="UTF-8"?> 
<api xmlns="http://ws.apache.org/ns/synapse" 
    name="admin--test" 
    context="/test/1.0.0" 
    version="1.0.0" 
    version-type="context"> 
    <resource methods="POST" url-mapping="/*" faultSequence="fault"> 
     <inSequence> 
     <filter source="$ctx:AM_KEY_TYPE" regex="PRODUCTION"> 
      <then> 
       <property name="api.ut.backendRequestTime" 
         expression="get-property('SYSTEM_TIME')"/> 
       <send> 
        <endpoint name="admin--test_APIproductionEndpoint_0"> 
        <http uri-template="http://localhost:8080/sample2/api/company/upload"/> 
        </endpoint> 
       </send> 
      </then> 
      <else> 
       <sequence key="_sandbox_key_error_"/> 
      </else> 
     </filter> 
     </inSequence> 
     <outSequence> 
     <class name="org.wso2.carbon.apimgt.usage.publisher.APIMgtResponseHandler"/> 
     <send/> 
     </outSequence> 
    </resource> 
    <handlers> 
     <handler class="org.wso2.carbon.apimgt.gateway.handlers.security.CORSRequestHandler"> 
     <property name="apiImplementationType" value="ENDPOINT"/> 
     </handler> 
     <handler class="org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler"/> 
     <handler class="org.wso2.carbon.apimgt.gateway.handlers.throttling.APIThrottleHandler"> 
     <property name="policyKey" value="gov:/apimgt/applicationdata/tiers.xml"/> 
     <property name="policyKeyApplication" 
        value="gov:/apimgt/applicationdata/app-tiers.xml"/> 
     <property name="policyKey" value="gov:/apimgt/applicationdata/tiers.xml"/> 
     <property name="policyKeyApplication" 
        value="gov:/apimgt/applicationdata/app-tiers.xml"/> 
     <property name="id" value="A"/> 
     <property name="policyKeyResource" 
        value="gov:/apimgt/applicationdata/res-tiers.xml"/> 
     </handler> 
     <handler class="org.wso2.carbon.apimgt.usage.publisher.APIMgtUsageHandler"/> 
     <handler class="org.wso2.carbon.apimgt.usage.publisher.APIMgtGoogleAnalyticsTrackingHandler"> 
     <property name="configKey" value="gov:/apimgt/statistics/ga-config.xml"/> 
     </handler> 
     <handler class="org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler"/> 
    </handlers> 
</api> 

答えて

0

は、正しくヘッダを維持するためには、正しい変更が、それは、ESB 4.9.0の新機能ですpassthru-http.properties

http.headers.preserve=Content-Length,Content-Type 

に以下を追加することですそう多くは文書化されていませんが、あなたはこのブログでそれについて読むことができます:http://prabu-lk.blogspot.co.il/2015/09/how-to-preserving-http-headers-in-wso2.html

1

はそれが見えますContent-Typeヘッダーを保持するために/passthru-http.propertiesをinorderします。ただ、Ajanthan答えを強調するために

+0

それは正しいです。私は追加しました:http.headers。preserve = Content-Length、Content-Typeは、タイプと長さの両方を保持します(一部のサーバーはそれに依存しています)。 –

関連する問題