Click here to Skip to main content
15,745,306 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am new at WCF

During consuming rest wcf service of Post method getting error
The remote server returned an error: (400) Bad Request.

I get confused how to pass input parameters to service and how to get output from service..try to hard but not get output...

What I have tried:

Web.config at client side

            <binding name="WSHttpBinding_IPushOrderDataService" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="500000000" maxReceivedMessageSize="5000000"
                messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                <readerQuotas maxDepth="500000000" maxStringContentLength="5000000" maxArrayLength="500000000"
                    maxBytesPerRead="4096" maxNameTableCharCount="500000000" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="false" />
        <endpoint address=""
            binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IPushOrderDataService" 
            contract="ServiceReference2.IPushOrderDataService" name="WSHttpBinding_IPushOrderDataService">
                <dns value="localhost" />

code on default.cs

ServiceReference2.PushOrderDataServiceClient ok = new ServiceReference2.PushOrderDataServiceClient();

        ServiceReference2.PushOrderDataServiceClient wcfServiceClient = new ServiceReference2.PushOrderDataServiceClient();
        ServiceReference2.NewDataSet newresp = new ServiceReference2.NewDataSet();

        ServiceReference2.Customer cust = new ServiceReference2.Customer();
        // cust.BRCD="";
        cust.CUSTCD = "CC000100132";
        ServiceReference2.DocketList dock = new ServiceReference2.DocketList();

        dock.AgentID = "";
        dock.AwbNo = "";
        dock.Breath = "1";
        dock.CollectableAmount = "2800";
        dock.CustomerName = "suraj";

        dock.Height = "1";
        dock.IsPudo = "N";
        dock.ItemName = "i-phone";
        dock.Length = "1";
        dock.Mode = "C";
        dock.NoOfPieces = "3";
        dock.OrderConformation = "Y";
        dock.OrderNo = "475698231";
        dock.ProductCode = "213054";
        dock.PudoId = "";
        dock.RateCalculation = "Y";
        dock.ShippingAdd1 = "Pune";
        dock.ShippingAdd2 = "Pune";
        dock.ShippingCity = "Pune";
        dock.ShippingEmailId = "Pune";
        dock.ShippingMobileNo = "7276872768";
        dock.ShippingState = "Maharashtra";
        dock.ShippingTelephoneNo = "7276872768";
        dock.ShippingZip = "411041";
        dock.TotalAmount = "2999";
        dock.TypeOfDelivery = "Home Delivery";
        dock.TypeOfService = "Express";
        dock.UOM = "Per KG";
        dock.VendorAddress1 = "Pune";
        dock.VendorAddress2 = "Pune";
        dock.VendorName = "Shri";
        dock.VendorPincode = "411041";
        dock.VendorTeleNo = "7276872768";
        dock.Weight = "300";
Tom Wauters 23-Oct-16 4:59am    
Not sure what you are trying to do here.
As far as what I can see here, your newresp variable is empty.
You are filling the Customer and DocketList, but not the NewDataSet you are giving the service. Maybe it gets filled in another part of your code, there is somewhat little information here. Also there is no way for us to know what type the wcfServiceClient.PushOrderData_PUDO_New(); function in your service is expecting.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900