views:

281

answers:

2

I am working on creating a .asmx webservice to meet the specific needs of an integration environment and for the life of me I cannot figure out how to get one section of it to work. The key is that the request WSDL needs to be something like the following. (Note I removed the soap envelope and namespace information)

<methodOne>
    <myValue>string</myValue>
    <myDemoGroup>
        <myDemoGroupItem>string</myDemoGroupItem>
        <myDemoGroupItem2>string</myDemoGroupItem2>
    </myDemoGroup>
    <myComplexGroup>
        <mySubStructure>
            <subItem1>string</subItem1>
            <subItem2>string</subItem2>
        </mySubStructure>
    </myComplexGroup
</methodOne>

Now, I know how to take care of most of this, the method one tag is handled by the name of my parameter, and then the items inside are simply elements in the class. SO something like this gets everything except for "MyComplexGroup"

[Web Method]
public void MyWebMethod(MyWebMethodRequest methodOne)
{
    //Do my stuff
}

public class MyWebMethodRequest
{
    public string myValue {get; set;}
    public MyDemoGroupInfo myDemoGroup {get; set;}
}

public class MyDemoGroupInfo
{
    public string myDemoGroupItem {get; set;}
    public string myDemoGroupItem2 {get; set;}
}

The question is how to I define the "myComplexGroup" to allow the creation of multiple mySubStructure elements, while still outputting all items to the WSDL.

If I continue on and do something like this

public class MyComplexGroupInfo 
{
    public List<MySubStructureInfo> mySubStructure {get; set;}
}

public class MySubStructureInfo
{
    public string subItem1 {get; set;}
    public string subItem2 {get; set;}
}

I can then add public MyComplexGroupInfo myComplexGroup {get; set;} to the object and I will get part of it, but instead of listing subItem1 and subItem2 it simply says MySubStructureInfo with nil set to one.

How can I get around this?

A: 

Maybe an obvious question, but did you try using wsdl.exe to see what it spits out? You can always just use this for guidance (i.e. you don't have to use the class directly).

Marc Gravell
+2  A: 

If you have WSDL contract that needs to be implemented, you may try wsdl.exe /serverInterface to get service stub generated.

Ihar Voitka
Ah, I've never used that before. What do I have to pass to it?
Mitchel Sellers
wsdl in a file or url to it
Ihar Voitka