简体   繁体   中英

ASP.NET Web Service SoapException When Client Built With MSBuild

I have a .NET (2.0) Windows Forms application that uses an ASP.NET Web Service hosted as part of a .NET (3.5) Web site. The Web site is hosted on a Windows server running IIS7. When I run the Forms application in Visual Studio (2010), I am able to use the Web Service without a problem. However, when I build the Forms application with MSBuild (4.0), it builds and runs, but when the service is used the following exception is thrown:

System.Web.Services.Protocols.SoapException: Server was unable to read request. --->
System.InvalidOperationException: There is an error in XML document (the line number
varies). --->     System.FormatException: Input string was not in a correct format.

I used MS Network monitor to view the SOAP to see where the problem was in the XML document. It would appear that at least one tag isn't being parsed correctly. For example, MS Network monitor displays one of the apparently broken tags as follows:

- Element: XmlElement:<Country> - USA</
    - STag: <Country>
        - Tag: <Country>
            - TagName: Country
                Name: Country
    Content: USA</

An ETag (end tag) isn't recognized. The content should be "USA" and the ETag should be " </Country>. "

Why is this happening? Specifically, what could be the difference between the application running in Visual Studio and the one built with MSBuild that could cause this problem? I have compared the build output and they are the same files, but there are size differences between some of them.

It turns out that this was caused by out of date web service proxy classes. Updating web references in the client application fixed the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM