all groups > dotnet web services > october 2006 >
You're in the

dotnet web services

group:

WSDL to SOAP


WSDL to SOAP Siva
10/27/2006 3:55:01 AM
dotnet web services:
Hi all,

I want to Convert a WSDL to a SOAP message.

Is there any way to do this.

I am using .NET 2.0

Thanks in Advance
RE: WSDL to SOAP Claus Konrad
10/27/2006 10:25:01 AM
You are confusing concepts here.
The WSDL is defining the service and its types.
SOAP is merely the protocol used for communication. It is like trying to
convert a cow to a chicken; not the most likely conversion.

BTW: What is actually your reasoning for this request?
--
rgds.
/Claus Konrad

[quoted text, click to view]
RE: WSDL to SOAP Siva
10/31/2006 9:10:01 PM
Hi,

Thanks for your reply.

the wsdl will contain the xsd for the messages of an operations.

I want to generate a soap message template using that xsd, defined in the WSDL

by using xsd (WSDL) we can run a loop and generate it by programatically, my
question is , Is there any automated way like WSDL.exe, xsd.exe etc.?

Thanks in advance.

Thanks
Siva

[quoted text, click to view]
Re: WSDL to SOAP John Saunders
11/1/2006 7:07:56 AM
[quoted text, click to view]

What do you mean when you say "a soap message template"? WSDL.EXE and
XSD.EXE will both generate .NET classes. When your web service receives a
message, it will be deserialized into an object of the appropriate class.
When that web method returns, it will serialize the return object into SOAP
and will send it:

<?xml version="1.0"?>
<wsdl:definitions targetNamespace="urn:wsdl.example"
name="example"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:ex="urn:example"
xmlns:tns="urn:wsdl.example"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://schemas.xmlsoap.org/wsdl/
file:///c:/Program%20Files/Microsoft%20Visual%20Studio%208/Xml/Schemas/wsdl.xsd
http://schemas.xmlsoap.org/wsdl/soap/
file:///c:/Program%20Files/Microsoft%20Visual%20Studio%208/Xml/Schemas/wsdlSoap11Binding.xsd">
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:example"
xmlns="urn:example">
<xsd:element name="Request">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="x"
type="xsd:int"/>
<xsd:element name="y"
type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Response">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="y"
type="xsd:int"/>
<xsd:element name="x"
type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="RequestMessage">
<wsdl:part name="parameter"
element="ex:Request">
</wsdl:part>
</wsdl:message>
<wsdl:message name="ResponseMessage">
<wsdl:part name="result"
element="ex:Response">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="examplePT">
<wsdl:operation name="MyOperation">
<wsdl:input message="tns:RequestMessage">
</wsdl:input>
<wsdl:output message="tns:ResponseMessage">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="example"
type="tns:examplePT">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document"></soap:binding>
<wsdl:operation name="MyOperation">
<soap:operation style="document"
soapAction="urn:example"/>
<wsdl:input>
<soap:body use="literal"
parts="parameter"></soap:body>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"
parts="result"></soap:body>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="exampleService">
<wsdl:port name="examplePort"
binding="tns:example">
<soap:address location="http://example.com/MyService.asmx"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

Running "wsdl /server" on this file will produce:

//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.1.4322.2032
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------

//
// This source code was auto-generated by wsdl, Version=1.1.4322.2032.
//
using System.Diagnostics;
using System.Xml.Serialization;
using System;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Web.Services;


/// <remarks/>
[System.Web.Services.WebServiceBindingAttribute(Name="example",
Namespace="urn:wsdl.example")]
public abstract class exampleService : System.Web.Services.WebService {

/// <remarks/>
[System.Web.Services.WebMethodAttribute()]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("urn:example",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("Response",
Namespace="urn:example")]
public abstract Response
MyOperation([System.Xml.Serialization.XmlElementAttribute(Namespace="urn:example")]
Request Request);
}

/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:example")]
public class Request {

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public int x;

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public int y;
}

/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:example")]
public class Response {

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public int y;

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public int x;
}

You can now create your webservice class by deriving from this:

public class MyExampleService : exampleService
{
public override Response MyOperation(Request Request)
{
Response response = new Response();
response.x = Request.x;
response.y = Request.y;
return response;
}
}


I hope that helps. I've left off details (and getting it to build) simply
because it's time for me to leave for work!

John

AddThis Social Bookmark Button