WCF로 이미지를 보내려고하고 있는데,이 경우 어떻게됩니까?원격 서버에서 예기치 않은 응답을 반환했습니다. (400) 잘못된 요청, WCF
원격 서버에서 예기치 않은 응답을 보냈습니다 : (400) 잘못된 요청입니다.
다른 모든 것은 WCF로 보내려면 잘 작동하며 이미지는 그다지 크지 않습니다 ~ 90kb. 이것에 관해 많은 스레드를 발견했지만 도움이되는 것은 아무것도 없습니다. 크기 제한을 늘리려고했지만 작동하지 않습니다.
의 Web.config
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2000000" maxReceivedMessageSize="2000000"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="2000000" maxStringContentLength="2000000" maxArrayLength="2000000"
maxBytesPerRead="2000000" maxNameTableCharCount="2000000" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8732/Design_Time_Addresses/WcfDataLager/Service1/"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService"
contract="ServiceReference.IService" name="WSHttpBinding_IService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
의 app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="WcfDataLager.Properties.Settings.WebbshopConnectionString"
connectionString="Data Source=(local);Initial Catalog=Webbshop;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<bindings />
<client />
<services>
<service name="WcfDataLager.Service">
<endpoint address="" binding="wsHttpBinding" contract="WcfDataLager.IService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/WcfDataLager/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
페이지 코드입니다.
protected void btnAdd_Click(object sender, EventArgs e)
{
Produkt produkt = new Produkt();
produkt.Namn = txtNamn.Text;
produkt.Pris = Convert.ToDouble(txtPris.Text);
produkt.Beskrivning = txtbeskrivning.Text;
produkt.LagerAntal = Convert.ToInt32(txtAntal.Text);
produkt.Typ = txtGenre.Text;
//produkt.ImageAsByte = fupBild.FileBytes;
produkt.Bild = new System.Drawing.Bitmap(fupBild.PostedFile.InputStream);
using (ServiceReference.ServiceClient wcfClient = new ServiceReference.ServiceClient())
{
wcfClient.AddProdukt(produkt);
}
}
WCF 코드.
public void AddProdukt(Produkt produkt)
{
DataSetTableAdapters.ProduktTableAdapter itemsTA = new
WcfDataLager.DataSetTableAdapters.ProduktTableAdapter();
byte[] bmpAsByte;
using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
{
produkt.Bild.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
stream.Position = 0;
bmpAsByte = new byte[stream.Length];
stream.Read(bmpAsByte, 0, (int)stream.Length);
stream.Close();
}
produkt.ID = 7;
itemsTA.InsertProdukt(produkt.Namn, produkt.Pris, produkt.Beskrivning, produkt.LagerAntal, bmpAsByte);
itemsTA.InsertGenre(produkt.Typ, produkt.ID);
DataSet dataset = new DataSet();
itemsTA.Adapter.Update(dataset);
}
를 들어
당신은 내가 당신이 서비스 경계, 서비스, 소비자가 무엇을 의미하는지 정말 모르겠어요, 나에게 코드 예제를 표시 할 수 있습니다. – Frozendragon
원본 답변을 업데이트했습니다. 귀하의 정보를 위해, 서비스는 공공 운영과 관련된 것이며, 소비자는 운영을 호출하고자하는 것이며, 서비스 경계는 이들 사이의 분리입니다. –
+1 ... 나에게 많은 좌절감을 저장했습니다! 고맙습니다. – Sam