0
실버 라이트 앱에 웹캠이 있습니다. 이미지를 캡쳐하여 바이트 배열로 변환하고 WCF 서비스로 보냅니다. 다음은 이미지 캡처 코드는 다음과 같습니다Silverlight가 WCF 서비스에 바이트 배열을 전송하지 않습니다.
MessageBox.Show("about to capture");
cs.CaptureImageAsync();
CS는 카메라 소스이며 올바르게 구성합니다 (imagecapturecompleted 이벤트로). 이미지 캡처 완료되면이 코드를 실행합니다
MessageBox.Show("Image Caputred");
var img = e.Result.ToImage();
var encoder = new PngEncoder();
Stream stream = img.ToStreamByExtension("png");
byte[] file = null;
if (stream.Length > 512000)
{
img = ExtendedImage.Resize(img, 240, new NearestNeighborResizer());
stream = img.ToStreamByExtension("png");
}
if (stream.Length < 512000)
{
BinaryReader binary = new BinaryReader(stream);
file = binary.ReadBytes((int)stream.Length);
MessageBox.Show("Stream read into file with length: " + file.Length);
}
else
{
MessageBox.Show("file size too large");
}
MessageBox.Show("Process done");
cs.Stop();
label1.Content = "and answer is : " + file!= null ? file.Length.ToString() : "ERROR";
ServiceReference1.Service1Client obj = new ServiceReference1.Service1Client();
ServiceReference1.ITEM i = new ServiceReference1.ITEM { Image = file };
obj.DoWorkCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(obj_DoWorkCompleted);
obj.DoWorkAsync(i);
이이 서비스를 구성하는 asp.net 프로젝트 내 Web.config의이다 :
<system.serviceModel>
<services>
<service name ="AttendanceSystem.IService1" behaviorConfiguration="BasicHttpBinding_IService1">
<endpoint address="" binding="basicHttpBinding" contract="AttendanceSystem.IService1"/>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="BasicHttpBinding_IService1">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
을 그리고 여기에 대한 참조입니다 실버 라이트 응용 프로그램
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:48886/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
name="default" />
</client>
</system.serviceModel>
012,351,641에서 서비스
피들러 내 SVC는 서비스 파일에 대한 호출에 다음과 같은 메시지를 반환
HTTP/1.1 400 Bad Request
Server: ASP.NET Development Server/10.0.0.0
Date: Wed, 15 Jan 2014 09:17:26 GMT
X-AspNet-Version: 4.0.30319
Cache-Control: private
Content-Length: 0
Connection: Close
그래서 무슨 일이 일어나고 있는지?
UPDATE : 서비스 I가 작은 바이트 배열을 통과 할 때 오류없이 작동하는 것 (실시 예 BitConverter.GetBytes (123)뿐만 이미지가 전송 될 때 최대 한도 내에서 명백하게되는 실패)
을 구성하는 [WCF 추적]을 활성화 (http://msdn.microsoft.com/en-us/library/ms733025 (V = vs.110). aspx) 오류 정보를 살펴보십시오. – Alberto