Share via


Getting SOAP Root Element missing Exception

Question

Monday, January 4, 2010 6:09 PM

I am needing help debugging why I am getting the a SOAP Exception that has the message that the root element is missing.

Setup

C# .Net 3.5

I am building a project for a client. I added a web service to the project that will handle some third party integration. I used WSDL.exe to generate a service wrapper class for the service locally. I added the class to the project and modified it in two places. One, I removed the generated return class that some service methods return then added a reference to the namespace that the return class exists in. Two, I modified the constructor to the following: 

this.Url = "http://" + ConfigurationManager.AppSettings["ServiceURL"] + "/Service1.asmx";

Usage: (trimmed down) 

for (int i = 0; i < 2 && !calledService; i++ )

{

  try

  {

    response = new MyService().UpdateOrder(companyId, orderId, orderDate, shipDate, poNumber,

                                                                  salesTax, shippingCost, shippingInfoId, billToId, salesRepKey,

                                                                  customerNumber);

    calledService = true;

  }

  catch

  {

     // error reporting and such

  }

}

Error

An error occured in the Project: System.Web.Services.Protocols.SoapException With message: Server was unable to process request. > Root element is missing.

Function:ReadResponse

Error Message: Server was unable to process request. > Root element is missing.

Stack Trace:
     at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
     at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
     at MyService.UpdateOrder(Int32 companyId, Int32 orderId, DateTime orderDate, DateTime shipDate, String poNumber, String taxKey, Decimal shippingAmount, Int32 shipToId, Int32 billToId, String salesRepKey, String customerNumber)
     at Controls.ControlsOrder.CallUpdateOrderService(Boolean isQuote, Int32 companyId, Int32 orderId, DateTime orderDate, DateTime shipDate, String salesTax, Decimal shippingCost, Int32 shippingInfoId, Int32 billToId, Nullable`1 salesRepId, String customerNumber, String poNumber)

 

Further Notes

  • Actor, Node, Lang, and Detail properties of the SoapException were all blank. 

Problem

The second iteration of the loop works, while the first time fails with the above mentioned empty soap exception.

Thoughts, comments, or requests for further information to clarify?

All replies (4)

Monday, January 4, 2010 6:15 PM

Try updating the service reference using WSDL. 

If that doesn't work, post the code for UpdateOrder.

Coding Light - Illuminated Ideas and Algorithms in Software
Coding Light WikiLinkedInForumsBrowser


Monday, January 4, 2010 7:11 PM

Update the server reference how? 

Below is the auto-genned code for UpdateOrder in MyService.cs.

Code

    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost/VEABMService/UpdateOrder", RequestNamespace = "http://localhost/VEABMService", ResponseNamespace = "http://localhost/VEABMService", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
    public GenericResponse UpdateOrder(int companyId, int orderId, System.DateTime orderDate, System.DateTime shipDate, string poNumber, string taxKey, decimal shippingAmount, int shipToId, int billToId, string salesRepKey, string customerNumber)
    {
        object[] results = this.Invoke("UpdateOrder", new object[] {
                    companyId,
                    orderId,
                    orderDate,
                    shipDate,
                    poNumber,
                    taxKey,
                    shippingAmount,
                    shipToId,
                    billToId,
                    salesRepKey,
                    customerNumber});
        return ((GenericResponse)(results[0]));
    }

Thursday, February 11, 2010 2:02 PM

I am still getting this error on a client's server. What would cause this exception? I have never seen it on my developer machine so I am wondering if it's some sort of version issue with some component (IIS, .Net, etc). 


Monday, April 4, 2011 2:34 PM

 The similiar issue what i had resolved, please refer                

http://forums.asp.net/p/1665939/4367619.aspx/1?Re+Root+element+is+missing+at+System+Web+Services+Protocols+SoapHttpClientProtocol+Invoke

Regards,

Rama Selvam M.