Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 320735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:46:52+00:00 2026-05-12T08:46:52+00:00

I have created a C# .net 2.0 webservice. I need to capture the raw

  • 0

I have created a C# .net 2.0 webservice. I need to capture the raw XML sent from the client and validate it against an XSD and return any errors to the client. The webservice will allow the client to upload a list of widgets to our system.

The following is some background info:

I created an XSD to model a “Widget”, which is a complex object. It looks something like this:

<xs:element name="WidgetList">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="Widget" maxOccurs="unbounded" type="WidgetType" />
        </xs:sequence>
    </xs:complexType>
</xs:element>
<xs:complexType name="WidgetType">
    <xs:sequence maxOccurs="1" minOccurs="1">
        <xs:element name="Seller" type="AccountType" maxOccurs="1" minOccurs="1" />
        <xs:element name="Buyer" type="AccountType" maxOccurs="1" minOccurs="1" />
    </xs:sequence>
    <xs:attribute name="Market" type="MarketType" use="required" />
</xs:complexType>
<!-- etc... -->

Then, I used XSD.exe to generate classes from the xsd.
The Classes that are created are WidgetList, Widget, Seller, Buyer, etc.

Next, I created a webservice method to take the Upload. It looks like so:

[WebMethod]
[SoapHeader("SecurityAuthenticationHeader", Direction = SoapHeaderDirection.In)]
public string UploadWidgets(WidgetList wl)
{
    //Need to validate the XML against the XSD here.

    //Code to import...
}

Two questions:

  1. Is there a way that I can validate the raw XML sent from the client against my original XSD?
  2. Is there anything wrong with the way I have created this service?

UPDATE:
The reason I need to do this is that even though the XSD says fields are required or minOccurs=1, it seems that those properties are not required in the WSDL (Not really sure why).

This is what part of the WSDL looks like (removed unnecessary parts for brevity):

<s:schema elementFormDefault="qualified" targetNamespace="http://www.clearpar.com/XMLSchema">
  <s:element name="lt">
    <s:complexType>
      <s:sequence>
        <s:element minOccurs="0" maxOccurs="unbounded" name="LoanTrade" type="s1:LoanTradeType" /> 
      </s:sequence>
     </s:complexType>
   </s:element>
<s:complexType name="LoanTradeType">
  <s:sequence>
    <s:element minOccurs="0" maxOccurs="1" name="Seller" type="s1:AccountType" /> 
    <s:element minOccurs="0" maxOccurs="1" name="Buyer" type="s1:AccountType" /> 
  </s:sequence>
  <s:attribute name="Market" type="s1:MarketType" use="required" /> 
</s:complexType>
<s:complexType name="AccountType">
  <s:attribute name="Name" type="s:string" /> 
  <s:attribute name="ClientSystemID" type="s:string" /> 
</s:complexType>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T08:46:52+00:00Added an answer on May 12, 2026 at 8:46 am

    I don’t think that there’s a simple way to do this.

    There is an MSDN article on implementing a SoapExtension to perform schema validation. This is the route I took, with a few enhancements.

    It’s unfortunate that there is no automatic mechanism to validate against the WSDL, especially since the service inherently knows the schema already. I would be interested to know if this situation has changed in WCF: I’m porting my services now and would love it if they’ve solved this problem more elegantly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a webservice in .net 2.0, C#. I need to log some
I need to consume a SOAP web service from a C# .Net 4.0 client.
I have a XML string comming from a Rest WS that I created on
we have a server and i need a ASP.NET webservice to access to an
I have created Web-Service in asp.net with c# . Now i want to pass
I have a C# webservice in .net 4.0. The webservice will create a file
I have created firstly ASP.NET MVC 2 . and write more functionality. After I
I have created a ASP.NET website and deploy it in IIS 7 (in place
I have created a asp.net website and i added tooltip to a button by
I have created blank Asp.Net-MVC 3 web application and want to write my own

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.