467,864 Members | 1,905 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,864 developers. It's quick & easy.

Error adding a Web reference to a VS .NET project

Hi,

I'm trying to create a web service client in C# but I get stuck at one of
the first steps.
When adding a Web reference to the Visual Studio project; I get this error
(this is a translation, the English terms might not be exact) :

"Error in the custom tool : Impossible to import WebService/Schema.
Impossible to import binding 'cmsserverbinding' (it's the name of the binding
in my WSDL file) from namesapce 'urn:cms. Impossible to import operation
'GetRubriques'. The schema with targetNamespace='urn:cms' has an invalid
syntax. The attribute 'name' may not be present."

Here's the WSDL file of the Web Service I'm trying to reach :

<?xml version="1.0" encoding="ISO-8859-1"?>
<definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:si="http://soapinterop.org/xsd"
xmlns:tns="urn:cms" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="urn:cms">

<types><xsd:schema elementFormDefault="qualified" targetNamespace="urn:cms">

<xsd:complexType name="Rubrique">
<xsd:all>
<xsd:element name="id_rubrique" type="xsd:string" />
<xsd:element name="nom" type="xsd:string" />
</xsd:all>
</xsd:complexType>
<xsd:complexType name="Groupe">
<xsd:all>
<xsd:element name="id_groupe" type="xsd:string" />
<xsd:element name="nom" type="xsd:string" />
</xsd:all>
</xsd:complexType>

<xsd:element name="Rubriques">
<xsd:complexType name="tabRubriques">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:attribute ref="SOAP-ENC:arrayType"
wsdl:arrayType="cms:Rubrique[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>

<xsd:element name="Groupes">
<xsd:complexType name="tabGroupes">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="cms:Groupe[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>

<xsd:element name="string1" type="xsd:string">
</xsd:element>

<xsd:element name="string2" type="xsd:string">
</xsd:element>

</xsd:schema>
</types>

<message name="listeRubriquesResponse"><part name="parameters"
element="tns:Rubriques" /></message>
<message name="listeRubriquesRequest"><part name="parameters"
element="tns:string1" /></message>

<message name="listeGroupesResponse"><part name="parameters"
element="tns:Groupes" /></message>
<message name="listeGroupesRequest"><part name="parameters"
element="tns:string2" /></message>

<portType name="cmsserverPortType">
<operation name="getGroupes"><input
message="tns:listeGroupesRequest"/><output
message="tns:listeGroupesResponse"/></operation>
<operation name="getRubriques"><input
message="tns:listeRubriquesRequest"/><output
message="tns:listeRubriquesResponse"/></operation>
</portType>

<binding name="cmsserverBinding" type="tns:cmsserverPortType">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getGroupes">
<documentation>Liste des groupes du CMS</documentation>
<soap:operation soapAction="urn:cms#getGroupes" style="document"/>
<input><soap:body use="literal" namespace="urn:cms"/></input>
<output><soap:body use="literal" namespace="urn:cms"/></output>
</operation>
<operation name="getRubriques">
<documentation>Liste des rubriques du CMS</documentation>
<soap:operation soapAction="urn:cms#getRubriques" style="document"/>
<input><soap:body use="literal" namespace="urn:cms"/></input>
<output><soap:body use="literal" namespace="urn:cms"/></output>
</operation>

</binding>

<service name="cmsserver">
<port name="cmsserverPort" binding="tns:cmsserverBinding">
<soap:address
location="http://localhost/cms_test/backend/webservice/webservice.php"/></port>
</service>

</definitions>
I can't see what "name" attribute the error message refers to. I've tried to
remove each of them but removing the "name" attribute of an element either
generates another error message or doesn't change anything.

I've got the feeling that DotNet is particularly capricious when it comes to
web service description schemas.
For instance, the same WSDL is fully accepted by a web service client
written in PHP...
Nov 23 '05 #1
  • viewed: 3281
Share:
4 Replies
glebur -

My guess is that VS.Net is having trouble connecting to the server that
contains your .asmx file.

We use a webmethods call to get the latest product version number and a
list of sponsors from our main website (ex:
http://www.vinfo.com/Updates/TGPlugIn/ProductInfo.asmx).

You can download the source code listed below from www.TekGuard.com,
along with the project file and the Web Reference. This will let you
see how it is used in context with the .asmx file. We use the same code
for both our TekGuard Mail Server product and our Outlook anti-spam
plugin.

Look for the following section of code in "Bootstrap.cs":

<snippet>

#region TGPCheckUpdates
public void TGPCheckUpdates ()
{
// Already Checking?
if (m_thrChecking != null) return;

// Have we checked in the past week since startup?
if (!m_bCheckUpdates || (m_dtLastCheck.AddDays(VER_CHECKWEEKLY) >
DateTime.Now)) return;

// Create a new thread for the WebMethods call
m_thrChecking = new Thread(new
ThreadStart(TGPCheckUpdates_Thread));
m_thrChecking.Priority = ThreadPriority.Lowest;
m_thrChecking.IsBackground = true;
m_thrChecking.Start();
}
private void TGPCheckUpdates_Thread()
{
string NewVersion;
string[] Sponsors;

// Connect to VISI web service
// Note: This is done without sending any information about your
computer
if (CheckUpdates_WebMethod(out NewVersion, out Sponsors))
{
// Success - save last version check date
m_dtLastCheck = DateTime.Now;

// Update Sponsors list
m_PlugIn.Sponsors = Sponsors;

// New version available?
if (NewVersion != null) m_PlugIn.LogAlert("Start", "A newer
version (" + NewVersion + ") is available", null);
}

// Done checking
m_thrChecking = null;
}
private bool CheckUpdates_WebMethod (out string NewVersion, out
string[] Sponsors)
{
try
{
// Get VISI Product info using WebMethods call
ProductInfo Info = new ProductInfo();

// Set the timeout to be relaively short
Info.Timeout = WEB_TIMEOUT;

// Get this local (running) version
string ThisVersion =
Assembly.GetExecutingAssembly().GetName().Version. ToString();

// Future: Use split command to compare embedded values
string CurrentVersion = Info.getVersion();

// Return version status
NewVersion = (CurrentVersion.CompareTo(ThisVersion) > 0) ?
Info.getVersion() : null;

// Return sponsor list
Sponsors = Info.getSponsors();

// Success
return (true);
}
catch
{
// Assume no updates available if info not available
NewVersion = null;
Sponsors = null;
return (false);
}
}
#endregion
</snippet>
Posted by www.AndrewM.com [PostID 20050621]

Software Entrepreneurs, ISV's, Developers - Sell & Support your
programs with an 800# virtual auto-attendant:
www.VoiceInfo.com - <a href="http://www.VoiceInfo.com">
Virtual Office, Automated Phone Assistant, Web Access </a><br>

Developers, ISP's, Small Business Owners - Need a starting point
for an anti-spam email server, Outlook client, WebMail?
www.TekGuard.com - <a href="http://www.TekGuard.com">
Free Mail Server, Outlook PlugIn, WebMail, C# Source Code </a>

Nov 23 '05 #2
glebur -

My guess is that VS.Net is having trouble connecting to the server that
contains your .asmx file.

We use a webmethods call to get the latest product version number and a
list of sponsors from our main website (ex:
http://www.vinfo.com/Updates/TGPlugIn/ProductInfo.asmx).

You can download the source code listed below from www.TekGuard.com,
along with the project file and the Web Reference. This will let you
see how it is used in context with the .asmx file. We use the same code
for both our TekGuard Mail Server product and our Outlook anti-spam
plugin.

Look for the following section of code in "Bootstrap.cs":

<snippet>

#region TGPCheckUpdates
public void TGPCheckUpdates ()
{
// Already Checking?
if (m_thrChecking != null) return;

// Have we checked in the past week since startup?
if (!m_bCheckUpdates || (m_dtLastCheck.AddDays(VER_CHECKWEEKLY) >
DateTime.Now)) return;

// Create a new thread for the WebMethods call
m_thrChecking = new Thread(new
ThreadStart(TGPCheckUpdates_Thread));
m_thrChecking.Priority = ThreadPriority.Lowest;
m_thrChecking.IsBackground = true;
m_thrChecking.Start();
}
private void TGPCheckUpdates_Thread()
{
string NewVersion;
string[] Sponsors;

// Connect to VISI web service
// Note: This is done without sending any information about your
computer
if (CheckUpdates_WebMethod(out NewVersion, out Sponsors))
{
// Success - save last version check date
m_dtLastCheck = DateTime.Now;

// Update Sponsors list
m_PlugIn.Sponsors = Sponsors;

// New version available?
if (NewVersion != null) m_PlugIn.LogAlert("Start", "A newer
version (" + NewVersion + ") is available", null);
}

// Done checking
m_thrChecking = null;
}
private bool CheckUpdates_WebMethod (out string NewVersion, out
string[] Sponsors)
{
try
{
// Get VISI Product info using WebMethods call
ProductInfo Info = new ProductInfo();

// Set the timeout to be relaively short
Info.Timeout = WEB_TIMEOUT;

// Get this local (running) version
string ThisVersion =
Assembly.GetExecutingAssembly().GetName().Version. ToString();

// Future: Use split command to compare embedded values
string CurrentVersion = Info.getVersion();

// Return version status
NewVersion = (CurrentVersion.CompareTo(ThisVersion) > 0) ?
Info.getVersion() : null;

// Return sponsor list
Sponsors = Info.getSponsors();

// Success
return (true);
}
catch
{
// Assume no updates available if info not available
NewVersion = null;
Sponsors = null;
return (false);
}
}
#endregion
</snippet>
Posted by www.AndrewM.com [PostID 20050621]

Software Entrepreneurs, ISV's, Developers - Sell & Support your
programs with an 800# virtual auto-attendant:
www.VoiceInfo.com - <a href="http://www.VoiceInfo.com">
Virtual Office, Automated Phone Assistant, Web Access </a><br>

Developers, ISP's, Small Business Owners - Need a starting point
for an anti-spam email server, Outlook client, WebMail?
www.TekGuard.com - <a href="http://www.TekGuard.com">
Free Mail Server, Outlook PlugIn, WebMail, C# Source Code </a>

Nov 23 '05 #3
Hi,

Thanks for your answer, but the error actually occurs during the parsing of
the WSDL file (and my SOAP server is not in Dotnet but in PHP).

I removed the name attribute of the SOAP-ENC:Arrays, and it solved the
problem but I get another error message :

The element string2 has been imported twice for different reasons :
(primitiveMapping, membersMapping).
Does someone have any idea about what it means ?

PS : I'm sorry about all the & lt; and & gt; hieroglyphs in my first
message, but I can't do anything about it ;it's a shame you can't post XML
code in this newsgroup...
Nov 23 '05 #4
Hi,

Thanks for your answer, but the error actually occurs during the parsing of
the WSDL file (and my SOAP server is not in Dotnet but in PHP).

I removed the name attribute of the SOAP-ENC:Arrays, and it solved the
problem but I get another error message :

The element string2 has been imported twice for different reasons :
(primitiveMapping, membersMapping).
Does someone have any idea about what it means ?

PS : I'm sorry about all the & lt; and & gt; hieroglyphs in my first
message, but I can't do anything about it ;it's a shame you can't post XML
code in this newsgroup...
Nov 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by aualias | last post: by
4 posts views Thread by Lowell | last post: by
reply views Thread by Nikhil Patel | last post: by
16 posts views Thread by Paul S. Natanson | last post: by
8 posts views Thread by Jon Paal | last post: by
reply views Thread by andrew.j.matheny | last post: by
4 posts views Thread by =?Utf-8?B?Z3JlZw==?= | last post: by
reply views Thread by jack112 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.