C# 当我尝试以字节[]形式发送图像时,WCF服务请求错误
这里我展示了通过WCF函数上传图像的全部功能 每当我呼叫下面的服务时,我都会收到错误的请求。请找出我犯的错误 我的wcf服务: 我的服务界面:C# 当我尝试以字节[]形式发送图像时,WCF服务请求错误,c#,.net,web-services,wcf,rest,C#,.net,Web Services,Wcf,Rest,这里我展示了通过WCF函数上传图像的全部功能 每当我呼叫下面的服务时,我都会收到错误的请求。请找出我犯的错误 我的wcf服务: 我的服务界面: [OperationContract] [WebGet( ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/send?canvasbyte={im
[OperationContract]
[WebGet(
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "/send?canvasbyte={imgbyte}&EmployeeID={EmployeeID}")]
string sendresponse(Byte[] imgbyte, string EmployeeID);
我的SVC
public string sendresponse(Byte[] imgbyte, string EmployeeID)
{
db.GetExcuteNonQuery("update emp_tb_eob_Employee set Signature='" + imgbyte + "' where EmployeeID=" + EmployeeID);
return "Success";
}
网络配置文件
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<connectionStrings>
<add name="Databaseconnection" connectionString="Database=Test_Exenta;Server=192.168.1.XX;User ID=XXXXX;Password=XXXXX" providerName="System.Data.SqlClient" /></connectionStrings>
<system.web>
<httpRuntime maxUrlLength="2097151" maxQueryStringLength="2097151" maxRequestLength="2097151" requestValidationMode="2.0" relaxedUrlToFileSystemMapping="true" />
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="RestService.RestServiceImpl" behaviorConfiguration="ServiceBehaviour">
<host>
<baseAddresses>
<add baseAddress="http://192.168.1.11:5252" />
</baseAddresses>
</host>
<endpoint address="" binding="webHttpBinding" contract="RestService.IRestServiceImpl" behaviorConfiguration="web" bindingConfiguration="RESTServiceBinding">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="RESTServiceBinding" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" transferMode="Streamed" sendTimeout="00:01:00">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" />
<defaultDocument>
<files>
<remove value="Default.htm" />
<remove value="Default.asp" />
<remove value="index.html" />
<remove value="index.htm" />
<remove value="iisstart.htm" />
<remove value="default.aspx" />
<add value="RestServiceImpl.svc" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
< /代码> 您可以考虑将图像传递为<代码> Base64 < /代码>编码<代码>字符串< /代码>或<代码>流< /代码> .<
下面的链接很好地概括了这些选项:
您的服务方法似乎公开了SQL注入目标…我试图以流的形式发送图像。但我有以下错误,我试图发送我的图像作为流。但是我得到了以下错误“type'System.IO.Stream”,但是类型'System.IO.Stream'不能由'QueryStringConverter'转换。UriTemplate查询值的变量必须具有可以由'QueryStringConverter'转换的类型。我尝试以base64string的形式发送,但得到了404错误。实际上我需要通过url发送图像。