Asked by:
Error:Manual addressing is enabled on this factory, so all messages sent must be pre-addressed

Question
-
User1216489373 posted
Hi,
I am getting the error: Manual addressing is enabled on this factory, so all messages sent must be pre-addressed.
Code of my web.config is as below.//Service web.config <system.serviceModel> <services> <service name="RestWCF.Service1" behaviorConfiguration="Service1Behavior"> <!-- Service Endpoints --> <endpoint address="" binding="webHttpBinding" contract="RestWCF.IService1"> <!-- Upon deployment, the following identity element should be removed or replaced to reflect the identity under which the deployed service runs. If removed, WCF will infer an appropriate identity automatically. --> <identity> <dns value="localhost"/> </identity> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> </service> </services> <behaviors> <serviceBehaviors> <behavior name="Service1Behavior"> <!-- 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="true"/> </behavior> </serviceBehaviors> <endpointBehaviors> <behavior name="web"> <webHttp/> </behavior> </endpointBehaviors> </behaviors> </system.serviceModel>
//Client Web.config <system.serviceModel> <bindings> <webHttpBinding> <binding name="WebHttpBinding_IService1"> <!--<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" messageVersion="Soap12" writeEncoding="utf-8">--> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/> <!--</textMessageEncoding> <httpTransport />--> </binding> </webHttpBinding> </bindings> <client> <endpoint address="http://localhost:1932/Service1.svc" binding="webHttpBinding" bindingConfiguration="WebHttpBinding_IService1" contract="RestWCF.IService1" name="WebHttpBinding_IService1"/> </client> </system.serviceModel>
Please help me.Thanks,
RahulTuesday, March 12, 2013 8:27 AM
All replies
-
User-1662538993 posted
<client> <endpoint address="http://localhost:1932/Service1.svc" binding="webHttpBinding" bindingConfiguration="WebHttpBinding_IService1" contract="RestWCF.IService1" name="WebHttpBinding_IService1"/> </client>
Add something linke this after your client -
<behaviors> <endpointBehaviors> <behavior name="webhttp"> <webHttp/> </behavior> </endpointBehaviors> </behaviors>
Tuesday, March 12, 2013 8:58 AM -
User1216489373 posted
Hi,
Thanks for the reply.I have added the code.
<behaviors> <endpointBehaviors> <behavior name="web"> <webHttp/> </behavior> </endpointBehaviors> </behaviors>
but still it is giving the same error.Thanks,
RahulTuesday, March 12, 2013 9:09 AM -
User-1662538993 posted
Add -
<client> <endpoint address="http://localhost:1932/Service1.svc" binding="webHttpBinding" bindingConfiguration="WebHttpBinding_IService1" contract="RestWCF.IService1" name="WebHttpBinding_IService1"/> </client>
<endpoint address="http://localhost:1932/Service1.svc" binding="webHttpBinding" bindingConfiguration="WebHttpBinding_IService1" contract="RestWCF.IService1" name="WebHttpBinding_IService1" behaviorConfiguration="web"/>
Tuesday, March 12, 2013 9:52 AM -
User768703680 posted
Please, try to make your web config of your WCF in the below mentioned format
<?
xml version="1.0"
?>
<
configuration
>
<
system.web
>
<
compilation debug="false" targetFramework="4.0">
</
compilation
>
<
pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/></system.web
>
<
system.serviceModel>
<
serviceHostingEnvironment aspNetCompatibilityEnabled="false">
</
serviceHostingEnvironment>
<
services>
<
service name="Sales_Portal.SalesPortal_BusinessProperties" behaviorConfiguration="ServiceBehaviour">
<
endpoint address="" binding="webHttpBinding" contract="Sales_Portal.ISalesPortal_BusinessProperties" behaviorConfiguration="web" bindingConfiguration="WebHttpBindingWithJSON" >
</
endpoint>
</
service>
</
services
>
<
behaviors
>
<
serviceBehaviors
>
<
behavior name="ServiceBehaviour"
>
<
serviceMetadata httpGetEnabled="true"
/>
<
serviceDebug includeExceptionDetailInFaults="true"
/>
</
behavior
>
</
serviceBehaviors
>
<
endpointBehaviors>
<
behavior name="web">
<
webHttp
/>
</
behavior>
</
endpointBehaviors>
</
behaviors>
<
bindings
>
<
webHttpBinding>
<
binding name="WebHttpBindingWithJSON" crossDomainScriptAccessEnabled="true"
>
</
binding>
</
webHttpBinding>
</
bindings>
</
system.serviceModel
>
<
system.webServer>
<
modules runAllManagedModulesForAllRequests="true">
</
modules>
</
system.webServer>
</
configuration
>
Tuesday, March 12, 2013 10:05 AM -
User1216489373 posted
Thanks for the reply.
Now my error has changed: The remote server returned an unexpected response: (400) Bad request.
Any Idea, how can I resolve this error.
Thanks,
RahulTuesday, March 12, 2013 10:32 AM -
User-1662538993 posted
400 Bad Request means you are not sending the requested data in correct format.
So your service has started receiving the request and it is not in the right format.
If possible post here what data your service is looking for and what you are sending.
Tuesday, March 12, 2013 10:47 AM -
User1216489373 posted
Yes, I can post. My service
[ServiceContract] public interface IService1 { [OperationContract] [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Xml)] List<Employee> GetDetail(string Id); } [DataContract] public class Employee { int Id; //string stringValue = "Hello "; [DataMember] public int EmpId { get { return Id; } set { Id = value; } } [DataMember] public string FirstName { get; set; } [DataMember] public int Salary { get; set; } } }
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class Service1 : IService1 { SqlConnection con = new SqlConnection(ConnectionString); public List<Employee> GetDetail(string Id) { Employee emp=new Employee(); con.Open(); SqlCommand cmd = new SqlCommand("SELECT Id,FirstName,Salary FROM Emp WHERE Id='"+Id+"'",con); SqlDataReader dr; dr = cmd.ExecuteReader(); while (dr.Read()) { emp.EmpId =Convert.ToInt32( dr["Id"]); emp.FirstName = dr["FirstName"].ToString(); emp.Salary = Convert.ToInt32(dr["Salary"]); } con.Close(); List<Employee> lstemp = new List<Employee>(); lstemp.Add(emp); return lstemp; }
Code at my Front End
protected void Button1_Click(object sender, EventArgs e) { Service1Client sc = new Service1Client(); List<Employee> emp = sc.GetDetail(TextBox1.Text); if (emp != null && emp.Count > 0 && emp[0].EmpId != 0) { Label1.Text = emp[0].EmpId.ToString(); Label2.Text = emp[0].FirstName.ToString(); Label3.Text = emp[0].Salary.ToString(); } else if(emp[0].EmpId==0) { Label1.Text = "Data Not Present"; } }
Thanks,
Rahul
Wednesday, March 13, 2013 2:38 AM