function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
David SomekhDavid Somekh 

Problem with WSDL import in visual studio

Hi All,

I am getting an error while trying to add web reference in visual studio 2005:

 

The document at the url file:///C:/Users/Emil Kalin/Desktop/enterprize.wsdl was not recognized as a known document type.
The error message from each known type may help you fix the problem:
- Report from 'DISCO Document' is 'Data at the root level is invalid. Line 2, position 1.'.
- Report from 'WSDL Document' is 'There is an error in XML document (2, 1).'.
  - Data at the root level is invalid. Line 2, position 1.
- Report from 'XML Schema' is 'Data at the root level is invalid. Line 2, position 1.'.

 

and also:

Invalid at the top level of the document. Error processing resource 'file:///C:/Users/Emil Kalin/Desktop/enterprize.wsdl'. ...

<?xml version="1.0" encoding="UTF-8" ?>

Has any one any idea? I have generated an enterprise WSDL file and copies all its content

from the browser window with the WDSL xml file.

 

The begining of the file:

<?xml version="1.0" encoding="UTF-8" ?>
- <!--
Salesforce.com Enterprise Web Services API Version 20.0
Generated on 2011-01-05 14:16:48 +0000.

Package Versions:
Aspira XObject (Version: 1.20, Namespace: aspirax)
PRM (Version: 1.2, Namespace: xforce_prm)
Salesforce for Google AdWords (Version: 1.2, Namespace: sfga)
CountryComplete (Version: 1.2, Namespace: pw_cc)
iCalendar Export (Version: 1.4, Namespace: icalendar)

Copyright 1999-2011 salesforce.com, inc.
All Rights Reserved


  -->
 <definitions targetNamespace="urn:enterprise.soap.sforce.com" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="urn:enterprise.soap.sforce.com" xmlns:fns="urn:fault.enterprise.soap.sforce.com" xmlns:ens="urn:sobject.enterprise.soap.sforce.com">
 <types>
 <schema elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:sobject.enterprise.soap.sforce.com">
  <import namespace="urn:enterprise.soap.sforce.com" />
- <!--  Base sObject (abstract)
  -->
- <complexType name="sObject">
- <sequence>
  <element name="fieldsToNull" type="xsd:string" nillable="true" minOccurs="0" maxOccurs="unbounded" />
  <element name="Id" type="tns:ID" nillable="true" />
  </sequence>
  </complexType>
- <complexType name="AggregateResult">
- <complexContent>
- <extension base="ens:sObject">
- <sequence>

 

Thank you all!

 

SuperfellSuperfell

It looks like you cut'n'pasted it from the browser, which won't work as you get all the - expand/collapse items which make the xml invalid. you want to right click on the wsdl link and click save as.

adamproadampro

Thank you for the example. I still seem to be getting an error so I think there is something wrong with the way I reference the WSDLs. I obtained the WSDLs by generating them in the UI, right clicked, and clicked "Save As". The content then downloaded as an xml file. In Visual Studio 2010, I went under Project>Add Service Reference>Advanced>Add Web Reference and located the file in my local directory. Lastly, I named the reference and clicked add reference.

 

When I try running the code, it returns this error to me:

 

Error	4	The type or namespace name 'metadata' could not be found (are you missing a using directive or an assembly reference?)	C:\Users\Adam\documents\visual studio 2010\Projects\AutoFollowApplication\AutoFollowApplication\Program.cs	244	17	AutoFollowApplication

 

This happens for both WSDLs I referenced. Is there anything obvious I'm doing wrong here?

SuperfellSuperfell

Its sounds like there's a mix up on namespace/class names, check in the generated source code for the package names, and adjust your using's to suit.