2015-06-04 74 views
0

我有肥皂SVC Web服務,這些都是我的WS方法:PHP來WCF與SoapClient的 - 請求實體太大

StoreService.svc.cs

namespace StoreServices 
{ 
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] 
    public class StoreService : IStoreService 
    { 
     public bool SaveCarData(Car car) 
     { 
      //Some code 
     } 
    } 
} 

IStoreService.cs

namespace StoreServices 
{ 
    [ServiceContract] 
    public interface IStoreService 
    { 
     [OperationContract] 
     [WebInvoke(Method = "POST", UriTemplate = "/SaveCarData", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)] 
     bool SaveCarData(Car car); 
    } 
} 

在我的WS web.config中,我已經調用了所有緩衝區來發送和接收大數據:

的web.config

<system.web> 
    <httpRuntime targetFramework="4.0" maxRequestLength ="2147483647" executionTimeout="999999"/> 
    </system.web> 
    <system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_IService" receiveTimeout="10:00:00" closeTimeout="10:00:00" 
      sendTimeout="10:00:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" 
      maxReceivedMessageSize="2147483647" openTimeout="10:00:00" /> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://myDomain.pt/WStore/StoreService.svc" 
     binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService" 
     contract="StoreServices.IStoreService" 
     name="BasicHttpBinding_IService" /> 
    </client> 
    </system.serviceModel> 

我的客戶打電話給我的服務是這樣的:

​​

我的客戶已經開啓在here說,他的 「緩衝區」 等。

現在的問題是:當我的客戶發送一個「短」 Car.ImageBase64字符串這工作得很好,但是當Car.ImageBase64字符串是巨大的,他可以和我的WS溝通,並得到這個錯誤:請求實體過大

短ImageBase64例如:

class Car 
{ 
    public $Id=0; 
    public $Name="My new car"; 
    public $Description=""; 
    public $ImageBase64="data:image/jpg;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7"; 
} 

巨大ImageBase64例如:

我的ImageBase64字符串示例太大,無法插入到此問題表單中。請在here中插入url「http://d3eaqdewfg2crq.cloudfront.net/wp-content/uploads/carousel/main-reporting/report.png」,並將其編碼爲base64。

什麼問題,我們該如何解決這個問題?我模擬了我的客戶端通信來測試一些事情,我發現他正在發出一個http GET請求。我認爲這可能是問題,我想將其更改爲http POST。我如何在PHP代碼中執行此操作?

Error php request headers

我也試圖改變我的web配置像this但我得到了一個「SOAP-ERROR:解析WSDL:找不到...」錯誤

回答

0

解決後!許多搜索和修改我終於用一個新的web.config改變了問題,我怎麼沒有客戶端端點,但是所有與我的WS通信的客戶端的服務器端點,我還需要創建一個新的服務(svc和接口文件)同樣的WCF項目),並將我的web.confi更改爲:

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_IStoreService" 
       receiveTimeout="10:00:00" 
       closeTimeout="10:00:00" 
       sendTimeout="10:00:00" 
       maxBufferPoolSize="2147483647" 
       maxBufferSize="2147483647" 
       maxReceivedMessageSize="2147483647" 
       openTimeout="10:00:00"/> 
     <binding name="BasicHttpBinding_IServiceIntegration" 
       receiveTimeout="10:00:00" 
       closeTimeout="10:00:00" 
       sendTimeout="10:00:00" 
       maxBufferPoolSize="2147483647" 
       maxBufferSize="2147483647" 
       maxReceivedMessageSize="2147483647" 
       openTimeout="10:00:00"> 
        <readerQuotas 
         maxDepth="2147483647" 
         maxStringContentLength="2147483647" 
         maxArrayLength="2147483647" 
         maxBytesPerRead="2147483647" 
         maxNameTableCharCount="2147483647" /> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <services> 
    <service name="StoreServices.StoreService" behaviorConfiguration="StoreServicesBehavior"/> 

     <service name="StoreServices.IntegrationService" behaviorConfiguration="IntegrationServicesBehavior"> 
     <endpoint address="" 
        binding="basicHttpBinding" 
        contract="StoreServices.IIntegrationService" 
        bindingConfiguration="BasicHttpBinding_IServiceIntegration" /> 
     <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" /> 
     </service> 

    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="StoreServicesBehavior"> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
     </behavior> 

     <behavior name="IntegrationServicesBehavior"> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <protocolMapping> 
    </protocolMapping> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"> 
     <serviceActivations> 
     <add factory="System.ServiceModel.Activation.WebServiceHostFactory" 
      relativeAddress="./StoreServices/StoreService.svc" 
      service="StoreServices.StoreService" /> 
     </serviceActivations> 
    </serviceHostingEnvironment> 
    </system.serviceModel>