Baris Turkoglu

Baris Turkoglu

  • NA
  • 14
  • 29.9k

Consuming webservice

Apr 20 2012 10:57 AM
Hi again.

I'm going to develop a client for a company that uses a webservice from another company.
The company that holds the webservice, have provided me with two wsdl files, two xsd files, one app.config file, and one reference.cs file.

when I try to send this to the webservice I get a "Cocdata provided is not a valid XML document 's' is undeclared prefix, Line 1 position 2."

             // Instantiate the WebProxy class
            WebProxy myProxy = new WebProxy("http://hidden.com:80", true);
            myProxy.Credentials = new NetworkCredential("username", "password", "domain");

            // Instantiate the WebService class
            CoCExchange.CoCExchangeWse client = new CoCExchange.CoCExchangeWse();

            //Set the proxy to the Client
            client.Proxy = myProxy;

             // Apply credentials as clear-text
            client.SetClientCredential(new Microsoft.Web.Services3.Security.Tokens.UsernameToken("username", "pass", Microsoft.Web.Services3.Security.Tokens.PasswordOption.SendPlainText));

            // Apply relevant policy
            client.SetPolicy(new UsernameOverTransportPolicy());

            // The XML string containing the CoC document to be submitted
            string coCDocument = "<s:Body><SubmitVehiclePriceCalculationIdentifiers xmlns='https://hidden'><vehicleIdentificationNumber>123456789123</vehicleIdentificationNumber><identifiers xmlns:i='http://hidden'><PriceCalculationIdentifier><FieldName>Marque</FieldName><Value>Marque of the product</Value></PriceCalculationIdentifier><PriceCalculationIdentifier><FieldName>ModelCode</FieldName><Value>String with the technical code for a commercial model name</Value></PriceCalculationIdentifier></identifiers></SubmitVehiclePriceCalculationIdentifiers></s:Body>";
            
            // Submit the document
            CoCExchange.VehicleReceipt receipt = client.SubmitCoC(coCDocument, false, true);
           
            client.Dispose();

            MessageBox.Show(string.Format("ReceiptId={0}\nVehicleIdentificationNumber={1}", receipt.ReceiptId, receipt.VehicleIdentificationNumber));


Do someone see any problem in the XML string ... the XML string is just a test..

Do I have to include the xsd and wsdl files in the project? I don't know what I'm doing wrong here .. :(

Appriciate any help.

Best regards
Baris

Answers (5)