2017-10-24 10 views
0

I'meと私porpouseはGUID名で一時ファイルに画像をアップロードし、コルドバ& Facebookのプラグインといくつかのソーシャルメディアで共有するためにそれを使用することですJavascriptをPHPとPHP WS年代に新しいコールNusoap WS

私はこのWSを持っていると私はAjaxを介して、それを呼び出すようにしようとしているが、それでも私は、このエラー与える:' 'は、このサービスのWSDLで定義されていません

操作を、客観的には画像をアップロードすることである(WSが働いています私はSoapUIでテストしました)、イメージをうまくアップロードしてください。

server.phpという

  <?php 
      error_reporting(0); 
      require_once('config/nusoap.php'); 
      $server = new soap_server(); 

      $server->configureWSDL('File Transfer Using Nusoap', 'urn:fileTransferwsdl'); 

      $server->register('transfer_file',                
       array('filename' => 'xsd:string','fileAsEndcodedString' => 'xsd:string'), 
       array('return' => 'xsd:string'), 
       'urn:fileTransferwsdl',                 
       'urn:fileTransferwsdl#transferFile', 
       'rpc', 
       'encoded', 
       'Transfer any file using web service' 
      ); 
      // Define the method as a PHP function 
      function transfer_file($pFilename,$pEncodedString) {       
         $decodedData=base64_decode($pEncodedString); 
         $fp = fopen("uplodedimages/".$pFilename, 'w'); 
         fwrite($fp, $decodedData); 
         fclose($fp); 
         return 'Your file is transfer to server successfully file name is -, ' . $pFilename; 
      } 


      // Use the request to (try to) invoke the service 
      $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ''; 
      $server->service($HTTP_RAW_POST_DATA); 
      $server->register("transfer_file"); 
      //$server->service(file_get_contents("php://input")); 
      ?> 

AJAX METHOD

var soapRequest; 
    try { 
     soapRequest = "<soapenv:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:urn='urn:fileTransferwsdl'>< soapenv:Header/>< soapenv:Body><urn:transfer_file soapenv:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'><filename xsi:type='xsd:string'>" + filename + "</filename><fileAsEndcodedString xsi:type='xsd:string'>" + fileasString + "</fileAsEndcodedString></urn: transfer_file ></soapenv: Body ></soapenv: Envelope >"; 
     console.log("callWS2"); 

     $.ajax({ 
      type: "POST", 
      url: wsUrl, //http://localhost/server.php 
      contentType: "xml", 
      dataType: "xml", 
      data: soapRequest, 
      success: succeeded, 
      error: queryError 
     }); 

は間違った、またはContentTypeをリクエストですか?助けてくれてありがとう

+0

は、あなたのcontentTypeが間違っていると考えて - それは 'contentTypeのでなければなりませんように見える: "text/xmlで"、' [WebサービスへのjQueryのAjaxのポスト]の –

+0

可能な複製(https://stackoverflow.com/questions/3099369/jquery-ajax-post-to-web-service) –

答えて

0

私はこの問題を見つけた。

第一:リクエストは、いくつかのスペース

2SDを持っている:私は、コンテンツセキュリティポリシーとの接続の問題を発見ので、私はこの例外を追加:デフォルト-srcの「自己」のデータを:ギャップ:https://ssl.gstatic.comhttp://myWebserviceSite.com/

3番目:このcontentTypeを "xml"、dataType: "xml"をこのcontentType: "text/xml"、dataType: "text/xml"に変更します。

そして、すべてのコルドバとブラウザに取り組んでいる=)