TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
trung nguyen
NA
1
1.6k
upload image android
Dec 10 2012 11:22 PM
I have a trouble about upload image from client android to webservice. In client , i convert image to base64 string. But my service can't receive this base64tring.
I test service by Fidder and the error is : 400 bad request.
This my web.config :
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere" />
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="500000">
</jsonSerialization>
</webServices>
</scripting>
</system.web.extensions>
<system.net>
<mailSettings>
<smtp>
<network host="mail.test.com" port="25" userName="
[email protected]
" password="*"/>
</smtp>
</mailSettings>
</system.net>
<connectionStrings>
<add name="VLDBConnectionString1" connectionString="Data Source=THOINX00861-PC;Initial Catalog=VLDB;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="VLDBConnectionString" connectionString="Data Source=KHANH-PC;Initial Catalog=VLDB;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="VLDBConnectionString3" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=VLDB;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="VLDBConnectionString2" connectionString="Data Source=54.251.59.102;Initial Catalog=VLDB;Integrated Security=False;User ID=vlocation;Password=v$#FDAF92"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</modules>
</system.webServer>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<standardEndpoints>
<webHttpEndpoint>
<!--
Configure the WCF REST service base address via the global.asax.cs file and the default endpoint
via the attributes on the <standardEndpoint> element below
-->
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
</webHttpEndpoint>
</standardEndpoints>
<services>
<service name="MyService.MyService" behaviorConfiguration="MyService.MyServiceBehaviour" >
<endpoint address=""
binding="webHttpBinding"
contract="MyService.IMyService"
behaviorConfiguration="maxRequest">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="maxRequest">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors >
<behavior name="MyService.MyServiceBehaviour">
<dataContractSerializer maxItemsInObjectGraph="4194304"/>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
and the webservice method (just to check webservice have receive of not.)
[WebInvoke(Method = "POST", UriTemplate = "/File",
RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml)]
public bool UploadFile(Stream fileContents)
{
string email, itemtId, codeimg, format;
using (StreamReader reader = new StreamReader(fileContents))
{
string[] separators = { "{\"", "\":\"", "\",\"", "\"}", "email", "format", "stringcodeimg", "itemid" };
string contents = reader.ReadToEnd();
string[] words = contents.Split(separators, StringSplitOptions.RemoveEmptyEntries);
email = words[0];
format = words[1];
codeimg = words[2];
itemtId = words[3];
}
return true;
}
Reply
Answers (
0
)
How do I fix this convert error? Is this a bug?
How to insert and play video songs