SOAP Message contains an extra tag after generation from WSCF Blue in Visual Studio 2008
I'm using Visual Studio 2008 to write a simple web-service but have been running into some problems. You might need to format my
The full expected message is something along the lines of:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace = "http://www.website.com/WS/"
elementFormDefault = "qualified"
xmlns = "http://www.website.com/WS/"
xmlns:xs = "http://www.w3.org/2001/XMLSchema"
>
<xs:element name="QUERYFOOTBALL">
<xs:complexType>
<xs:sequence>
<xs:element name="KEY" minOccurs="1" maxOccurs="1" type="xs:string" />
<xs:element name="FOOTBALL">
<xs:complexType>
<xs:sequence>
<xs:element name="HEADER" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="TEAM_ID" minOccurs="1" maxOccurs="1" type="xs:string" />
<xs:element name="MATCH_ID" minOccurs="1" maxOccurs="1" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GAME" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="ONE" minOccurs="1" maxOccurs="1" type="xs:string" />
<xs:element name="TWO" minOccurs="1" maxOccurs="1" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
However when I generate the service the SOAP message layout/call appears like so
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<QueryFootball xmlns="http://www.website.com/WS/">
<QUERYFOOTBALL>
<KEY>string</KEY>
<FOOTBALL>
<HEADER>
<TEAM_ID>string</TEAM_ID>
<MATCH_ID>string</MATCH_ID>
</HEADER>
<GAME>
开发者_Python百科 <ONE>string</ONE>
<TWO>string</TWO>
</GAME>
</FOOTBALL>
</QUERYFOOTBALL>
</QueryFootball>
</soap:Body>
</soap:Envelope>
My actual C# code looks like this:
namespace FootballSimulator
{
[System.ServiceModel.ServiceBehaviorAttribute(InstanceContextMode=System.ServiceModel.InstanceContextMode.PerCall, ConcurrencyMode=System.ServiceModel.ConcurrencyMode.Single)]
public class FootballSimulator : IFootballSimulator
{
public virtual QUERYFOOTBALLRESPONSE QUERYFOOTBALL(QUERYFOOTBALL request)
{
throw new System.NotImplementedException();
}
}
}
I guess my question is how can I edit the Schema/WSCFBlue so that it doesn't force that extra in the SOAP request?
I would really appreciated any advice/guidance you could give. I can give you an outline to what I did:
- In visual studio I right clicked my 2 schemas (request and response message) and selected WSCFblue then Create WSDL Interface Description
- I selected the correct schemas/ports and gave them message in a name of QUERYFOOTBALL and the message out a name of QUERYFOOTBALLRESPONSE
- I right clicked the WSDL that was generated in above steps and went selected WSCFblue then Generate Data Contract Code (which is does and gives me my objects QUERYFOOTBALL and QUERYFOOTBALLRESPONSE)
- I right clicked the WSDL and selected WSCFblue then Generate Web Service Code
If there is anything obvious that I am doing wrong I would really appreciated it if you can show me what it is. It looks asthough the method name is the causing the additional tag to be added around the expected soap message. In my schema after QUERYFOOTBALL element is another element called KEY, this is the reason I cannot just take out QUERYFOOTBALL and create an object called "FOOTBALL".
What I want the web-service to accept is this:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<QUERYFOOTBALL>
<KEY>string</KEY>
<FOOTBALL>
<HEADER>
<TEAM_ID>string</TEAM_ID>
<MATCH_ID>string</MATCH_ID>
</HEADER>
<GAME>
<ONE>string</ONE>
<TWO>string</TWO>
</GAME>
</FOOTBALL>
</QUERYFOOTBALL>
</soap:Body>
</soap:Envelope>
Really appreciate any help you can give, look forward to hearing your experiences/opinions/advice
Better late than never....
Try adding this to your Web Method:
[SoapDocumentMethod(ParameterStyle = SoapParameterStyle.Bare)]
精彩评论