2010-11-24 15 views
0

WFCサーバーまたはクライアントの設定に問題があります。 私は、サーバーに画像をアップロードしようとすると、私はエラーを取得する:WCFがサーバーに画像をアップロードするバインドエラー

Content Type multipart/related; type="application/xop+xml"; 
start="<http://tempuri.org/0>"; 
boundary="uuid:868d52b2-10f6-4661-8784-bf81f3a84c16+id=1"; 
start-info="application/soap+xml" was not supported by service http://localhost:8080/PhotoService/. The client and service bindings may be mismatched. 

誰かがサーバーとクライアントを設定するか、私はミスを手に入れたところ私に教えて私を助けてもらえますか?

私はこのような構成を持っている:クライアント側で

:サーバー側で

<configuration> 
    <system.serviceModel> 
     <bindings> 
      <wsHttpBinding> 
       <binding name="WSHttpBinding_IPhotoService" maxReceivedMessageSize ="2000000" messageEncoding="Mtom" maxBufferPoolSize="2000000"> 
       <readerQuotas maxArrayLength="50000000" maxStringContentLength="2000000"/> 
        <security mode="None"> 
        <transport> 
         <extendedProtectionPolicy policyEnforcement="Never" /> 
        </transport> 
        </security> 
       </binding> 
      </wsHttpBinding> 
     </bindings> 
     <client> 
      <endpoint address="http://localhost:8080/PhotoService/" 
       binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IPhotoService" 
       contract="PhotoService.IPhotoService" name="WSHttpBinding_IPhotoService"> 
       <identity> 
        <dns value="localhost" /> 
       </identity> 
      </endpoint> 
     </client> 
    </system.serviceModel> 
</configuration> 

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <system.web> 
    <compilation debug="true" /> 
    </system.web> 
    <!-- When deploying the service library project, the content of the config file must be added to the host's 
    app.config file. System.Configuration does not support config files for libraries. --> 
    <system.serviceModel> 
    <services> 
     <service name="PhotoService.PhotoService"> 
     <endpoint address="" binding="wsHttpBinding" contract="PhotoService.IPhotoService"> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8080/PhotoService/" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="wsHttp" maxReceivedMessageSize ="2000000" messageEncoding="Mtom" maxBufferPoolSize="2000000"> 
      <readerQuotas maxArrayLength="50000000" maxStringContentLength="2000000"/> 
      <security mode="None"> 
      <transport> 
       <extendedProtectionPolicy policyEnforcement="Never" /> 
      </transport> 
      </security> 
     </binding> 
     </wsHttpBinding> 

    </bindings> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <serviceMetadata httpGetEnabled="True" /> 
      <serviceDebug includeExceptionDetailInFaults="True" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 
</configuration> 

クライアント側ソース:

private void AddPhoto() 
     { 
      try 
      { 
       Image image = Image.FromFile(WayToFile); 
       var obj = new PhotoData(); 
       obj.ID = Guid.NewGuid().ToString(); 
       obj.Image = Photo.ImageToByteArray(image); 
       obj.Title = _title; 
       obj.Description = _description; 
       using (var service = new PhotoServiceClient()) 
        service.InsertPhoto(obj); 
       AllPhotos.Add(new Photo(obj)); 
      } 
      catch(Exception ex) 
      { 
       MessageBox.Show(ex.Message); 
       return; 
      } 
     } 

     public static Image ByteArrayToImage(byte[] byteArrayIn) 
     { 
      var ms = new MemoryStream(byteArrayIn); 
      Image returnImage = Image.FromStream(ms); 
      return returnImage; 
     } 
     public static byte[] ImageToByteArray(Image imageIn) 
     { 
      var ms = new MemoryStream(); 
      imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); 
      return ms.ToArray(); 
     } 

サーバー側のソースを:

[DataContract] 
public class PhotoData 
{ 
    private string _id; 
    private string _title; 
    private string _description; 
    private byte[] _image; 

    [DataMember] 
    public string ID 
    { 
     set { _id = value; } 
     get { return _id; } 
    } 

    [DataMember] 
    public string Title 
    { 
     set { _title = value; } 
     get { return _title; } 
    } 

    [DataMember] 
    public string Description 
    { 
     set { _description = value; } 
     get { return _description; } 
    } 

    [DataMember] 
    public byte[] Image 
    { 
     set { _image = value; } 
     get { return _image; } 
    } 
} 

[ServiceContract] 
public interface IPhotoService 
{ 
    [OperationContract(IsOneWay = true)] 
    void InsertPhoto(PhotoData photo); 
} 

答えて

1

あなたは <endpoint address="" binding="wsHttpBinding" contract="PhotoService.IPhotoService">

+0

O行目にbindingConfiguration="wsHttp"を追加するには、サーバの設定では、サーバ のバインディング設定していないようですseens!あなたが正しいです!どのように私はそれを逃しましたか?ありがとう!すべて正常に動作します! – Leonid

関連する問題