Inherting from sealed "string" class? Or maybe I need an attribute?

  • Thread starter Thread starter Drebin
  • Start date Start date
D

Drebin

I need to make my web service interface support something so the
soap-request is something like this:

<SSNs>
<SSN />
<SSN />
</SSNs>

about the only way I could figure to do this is like by having that
parameter defined as:

public void Test(SSN[] SSNs)

where SSN is a struct or class. But that has been pretty messy, trying to
get that class to act like a string. because what I REALLY want is to define
it like this:

public void Test(string[] SSNs)

But that changes the soap-request to show up as:

<SSNs>
<string>string</string>
<string>string</string>
</SSNs>

So.. it seems I either need find an attribute to "rename" string.. or create
a class that acts just like string.. but I can't do that, because it's a
sealed class.

ANY ideas???


--
 
Drebin said:
I need to make my web service interface support something so the
soap-request is something like this:

<SSNs>
<SSN />
<SSN />
</SSNs>

Use the XML serialization attributes, like this:

[WebMethod]
public string HelloWorld( [XmlArray("SSNs")]
[XmlArrayItem("SSN")]
string [] SSNs )
{
string ret = string.Empty;
foreach(string s in SSNs)
ret += s;
return ret;
}

The SOAP body looks like:

<soap:Body>
<s0:HelloWorld>
<s0:SSNs>
<s0:SSN>555-11-2222</s0:SSN>
<s0:SSN>555-22-3333</s0:SSN>
</s0:SSNs>
</s0:HelloWorld>
</soap:Body>
 
Wow - I blew a whole morning on this!! I was getting close though, I was
trying XmlElement - but that didn't quite do it.

But what you put - is EXACTLY what I needed - and I have this problem in a
bunch of places, so this helps me even more.. I can't thank you enough!!!!

Mickey Williams said:
Drebin said:
I need to make my web service interface support something so the
soap-request is something like this:

<SSNs>
<SSN />
<SSN />
</SSNs>

Use the XML serialization attributes, like this:

[WebMethod]
public string HelloWorld( [XmlArray("SSNs")]
[XmlArrayItem("SSN")]
string [] SSNs )
{
string ret = string.Empty;
foreach(string s in SSNs)
ret += s;
return ret;
}

The SOAP body looks like:

<soap:Body>
<s0:HelloWorld>
<s0:SSNs>
<s0:SSN>555-11-2222</s0:SSN>
<s0:SSN>555-22-3333</s0:SSN>
</s0:SSNs>
</s0:HelloWorld>
</soap:Body>
 
Back
Top