473,388 Members | 941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

ServiceDescription.Types: Getting Type Information From Wsdl

I'm currently working an .net application (I can use 1.1 or 2.0 if needed)
that needs to read a wsdl file and generate another piece of code that can
use it. I'm encountering a problem where I cannot extract all of the type
information from the wsdl using any standard tools. I'm using HttpGet style
webservices if that makes any difference, but I want to be able to use any
type.

1. I've tried the ServiceDescription.Types and I cannot get the information
that way.
2. I've also tried using wsdl.exe, compiling the proxy, and the reflecting
on it. However, I've discovered that wsdl.exe only generates objects
representing the return type not the input type.
3. I've also tried using ServiceDescription and ServiceDescriptionImporter,
so that I would be able to walk the CODEDom;however, when I try that I get an
error that says NoCodeGenerated, yet wsdl.exe can generate it just fine.

If anyone has any suggestions workarounds 3rd party api's I'm extremely
interested. I'll use beta software :)
Nov 23 '05 #1
2 7705

"Danny Gagne" <Danny Ga***@discussions.microsoft.com> wrote in message
news:D6**********************************@microsof t.com...
I'm currently working an .net application (I can use 1.1 or 2.0 if needed)
that needs to read a wsdl file and generate another piece of code that can
use it. I'm encountering a problem where I cannot extract all of the type
information from the wsdl using any standard tools. I'm using HttpGet
style
webservices if that makes any difference, but I want to be able to use any
type.

1. I've tried the ServiceDescription.Types and I cannot get the
information
that way.
2. I've also tried using wsdl.exe, compiling the proxy, and the
reflecting
on it. However, I've discovered that wsdl.exe only generates objects
representing the return type not the input type.
3. I've also tried using ServiceDescription and
ServiceDescriptionImporter,
so that I would be able to walk the CODEDom;however, when I try that I get
an
error that says NoCodeGenerated, yet wsdl.exe can generate it just fine.

If anyone has any suggestions workarounds 3rd party api's I'm extremely
interested. I'll use beta software :)


I think using the ServiceDescriptionImporter class is your best bet. As far
as I know wsdl.exe uses this same ServiceDescriptionImporter class
internally to generate code from WSDL, so it should be able to process the
WSDL. Can you show us the code you are using and the WSDL?

Regards,
Sami
Nov 23 '05 #2
I wrote up a quick example:

C# code:

using System;
using System.IO;
using System.Web.Services.Description;
using System.Xml;
using System.CodeDom;

namespace ServiceDescriptionTest
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class ServiceTest
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Console.WriteLine ("Starting Test");

try
{
TextReader stringReader = new StreamReader ("test.wsdl");

Test (stringReader.ReadToEnd());
}
catch (Exception e)
{
Console.WriteLine ("Exception: " + e);
}

Console.WriteLine ("Test Over, press return");
Console.ReadLine ();
}

static void Test (string wsdl)
{
StringReader stream = new StringReader (wsdl);
XmlTextReader reader = new XmlTextReader (stream);

if (!ServiceDescription.CanRead (reader))
throw new Exception ("Unable to read the wsdl file: " +wsdl);

ServiceDescription service = ServiceDescription.Read (reader);
ServiceDescriptionImporter importer = new ServiceDescriptionImporter();

//possible protocols: SOAP (default), HttpGet, HttpPost
//importer.ProtocolName = "HttpGet"; -- commented out because it syas
it's not a valid protocol

importer.AddServiceDescription(service, "", "");

CodeNamespace @namespace = new CodeNamespace(ServiceDescription.Namespace);
CodeCompileUnit program = new CodeCompileUnit();

program.Namespaces.Add (@namespace);

ServiceDescriptionImportWarnings warnings = importer.Import(@namespace,
program);

Console.WriteLine("ServiceDescriptionImportWarning s value generated: " +
warnings.ToString());
}
}
}

WSDL:

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:s0="http://mitre.org/"
targetNamespace="http://mitre.org/" name="MapQuestService">
<types>
<s:schema targetNamespace="http://mitre.org/">
<s:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<s:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
<s:complexType name="AddressRequest">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="address"
type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="zipcode"
type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="country"
type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="state"
type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="city"
type="s:string"/>
</s:sequence>
</s:complexType>
<s:element name="Map" type="s:string"/>
</s:schema>
</types>
<message name="GetMapRequestHttpGetIn">
<part name="GetMapRequest" type="s0:AddressRequest"/>
</message>
<message name="GetMapResponseHttpGetOut">
<part name="Body" element="s0:Map"/>
</message>
<portType name="MapQuestHttpGet">
<operation name="Get-Map">
<input message="s0:GetMapRequestHttpGetIn"/>
<output message="s0:GetMapResponseHttpGetOut"/>
</operation>
</portType>
<binding name="MapQuestHttpGet" type="s0:MapQuestHttpGet">
<http:binding verb="GET"/>
<operation name="Get-Map">
<http:operation location="homesubmit"/>
<input>
<http:urlEncoded/>
</input>
<output>
<mime:mimeXml part="Body"/>
</output>
</operation>
</binding>
<service name="MapQuestService">
<port name="MapQuestHttpGetPort" binding="s0:MapQuestHttpGet">
<http:address location="http://www.mapquest.com/maps/map.adp"/>
</port>
</service>
</definitions>
"Sami Vaaraniemi" wrote:

"Danny Gagne" <Danny Ga***@discussions.microsoft.com> wrote in message
news:D6**********************************@microsof t.com...
I'm currently working an .net application (I can use 1.1 or 2.0 if needed)
that needs to read a wsdl file and generate another piece of code that can
use it. I'm encountering a problem where I cannot extract all of the type
information from the wsdl using any standard tools. I'm using HttpGet
style
webservices if that makes any difference, but I want to be able to use any
type.

1. I've tried the ServiceDescription.Types and I cannot get the
information
that way.
2. I've also tried using wsdl.exe, compiling the proxy, and the
reflecting
on it. However, I've discovered that wsdl.exe only generates objects
representing the return type not the input type.
3. I've also tried using ServiceDescription and
ServiceDescriptionImporter,
so that I would be able to walk the CODEDom;however, when I try that I get
an
error that says NoCodeGenerated, yet wsdl.exe can generate it just fine.

If anyone has any suggestions workarounds 3rd party api's I'm extremely
interested. I'll use beta software :)


I think using the ServiceDescriptionImporter class is your best bet. As far
as I know wsdl.exe uses this same ServiceDescriptionImporter class
internally to generate code from WSDL, so it should be able to process the
WSDL. Can you show us the code you are using and the WSDL?

Regards,
Sami

Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: David | last post by:
Hi everyone, I wonder how is it possible to make PHP SOAP extension convert the returned complex type to an instance of one of my classes. Here I give you a short example: complexTest.wsdl:...
2
by: Erik Klein | last post by:
I have a WebService whose WSDL contains the following snippet: <complexType abstract="true" name="Type"> <sequence> <element name="localId" nillable="true" type="xsd:string"/> <element...
1
by: Marko | last post by:
How would I go generating some user interface (winform/webform) from schema in WSDL <types> element ? So far I have been able to read operation and message information, now I need information about...
7
by: stephan querengaesser | last post by:
hi ng, i try to invoke a webservice-method with an filter-object, that contains value types. if i donīt want to filter the return value of the method, i have to pass a new instance of the...
4
by: Martin Ehrlich | last post by:
Hello NG. I've got a little problem with sharing types between webservices and clients. I've created a business class with public fields within a shared assembly like: public class Item {
1
by: louis_la_brocante | last post by:
Dear all, I am having trouble generating a client proxy for a webservice whose methods return a "complex" type. The type is complex in that it is a class whose members are a mix of primitive...
0
by: Thomas.Koerfer | last post by:
Hey guys, I googled for nearly 3 hours - but no result... We run a web-service and want to reach that service from Access. In the following part you see the wsdl content and the automatically...
0
by: Steve | last post by:
Hi All, I have a Python script that uses SOAPpy and I'm outputting all of the methods and info about the parameters... I'm having trouble getting information out of the __init__ parameter. ...
0
by: shaily | last post by:
hi I have a java web service called "Registration service" and C# client which is a consumer of that service java web service running under Tomcat has following interface API exposed ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.