cancel
Showing results for 
Search instead for 
Did you mean: 

WSDL Issue?

Former Member
0 Kudos

Hello All,

I am attempting to consume an SAP Web Service from a C# webapp in Visual Studio 2005. In the fairly recent past we have implemented EP3 and since that, I have not done this. In any event, when I navigate to the Solution Explorer in VS2005 and "Add Web Reference", it correctly shows the exposed web methods and their input parameters as well as the return type etc... In the "Web Reference Name" text box, I enter something like MYSAP and click "Add Reference". Everything seems to go well, but after I attempt to use the namespace "MYSAP", nothing comes up. When applying the "using" directive (i.e. using MYSAP; ), I get the error "The type or namespace name MYSAP could not be found (are you missing a using directive or an assembly reference)...".

As stated earlier, I have done this successfully in the past, but for some reason now it doesn't seem to be properly generating the proxy class / namespace in Visual Studio. The input and output parameters for the web method are simply of type string, so there shouldn't be any confusion there. I would also like to point out that this is not a Visual Studio issue as I can correctly reference a test web service (i.e. Amazon). Has anyone else experienced an issue similar to this? I've searched and search, but to this point have found nothing. Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Dennis,

does your generated proxy class successfully compiles? If not, then it's logical that the namespace of this proxy class is unknown.

The reason for asking is that there are 2 known issues with Visual Studio proxy generation via the WSDL of SAP webservices:

1) SAP also uses 'System' as phrase in its .wsdl definition; at runtime this will collapse with the standard System namespace at the WCF proxy side. To resolve this your must edit either the wsdl or the generated proxy code by a general renaming of System, eg rename to all capital SYSTEM

2) rename in the wsdl all instances of phrase "parameters" to "parameter". This is required to be able to read the WebService.

Best regards, William.

Former Member
0 Kudos

William,

Thank you for your response. I do not think that the proxy class is even being generated. While the *.discomap and *.wsdl file is being created under the MYSAP folder in the APP_WebReferences, I can not access anything by the name of MYSAP as it doesn't exist. This is what makes me thing that the proxy is not being generated. I have looked through the WSDL file and "System" does not occur anywhere in the file. There was one instance of "Parameters", but it made no difference for me after being changed to "Paramter".

Former Member
0 Kudos

Dennis,

so apparently the proxy generation (via svcutil) went wrong.

I suggest you try again, with the 'parameters' correction applied; and then post any error messages that appear in the output window in Visual Studio.

Also perhaps post the wsdl content.

Regards, William.

Former Member
0 Kudos

William,

I am not using svcutil, but simply right clicking in the solution explorer and using "Add Web Reference" to add the solution explorer. Below is my wsdl.

<wsdl:definitions targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style">

u2212

<wsdl:documentation>

<sidl:sidl/>

</wsdl:documentation>

u2212

<wsdl:types>

u2212

<xsd:schema attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style">

u2212

<xsd:element name="ZDpUserUnlock">

u2212

<xsd:complexType>

u2212

<xsd:sequence>

<xsd:element name="PUnlock" type="xsd:string" minOccurs="0"/>

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

</xsd:sequence>

</xsd:complexType>

</xsd:element>

u2212

<xsd:element name="ZDpUserUnlockResponse">

u2212

<xsd:complexType>

u2212

<xsd:sequence>

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

</xsd:sequence>

</xsd:complexType>

</xsd:element>

</xsd:schema>

</wsdl:types>

u2212

<wsdl:message name="ZDpUserUnlock">

<wsdl:part name="parameters" element="tns:ZDpUserUnlock"/>

</wsdl:message>

u2212

<wsdl:message name="ZDpUserUnlockResponse">

<wsdl:part name="parameter" element="tns:ZDpUserUnlockResponse"/>

</wsdl:message>

u2212

<wsdl:portType name="z_unlock_ws">

u2212

<wsdl:operation name="ZDpUserUnlock">

<wsdl:input message="tns:ZDpUserUnlock"/>

<wsdl:output message="tns:ZDpUserUnlockResponse"/>

</wsdl:operation>

</wsdl:portType>

</wsdl:definitions>

Former Member
0 Kudos

Hi Dennis,

this wsdl is incorrect, and therefore the svcutil (which is, by the way, used by Visual Studio upon proxy generation) cannot successfully read it in.

If you correct it like this:

1) add missing xml-namespaces

<wsdl:definitions

targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style"

xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"

xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"

xmlns:tns="urn:sap-com:document:sap:rfc:functions" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"

xmlns:xsd="http://www.w3.org/2001/XMLSchema">

2) remove the part:

<wsdl:documentation>

<sidl:sidl/>

</wsdl:documentation>

You can next successfully generate the webservice proxy (trust me, I tried )

For your convenience I include here the entire corrected wsdl:

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

<wsdl:definitions

targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style"

xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"

xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"

xmlns:tns="urn:sap-com:document:sap:rfc:functions" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"

xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<wsdl:types>

<xsd:schema attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style">

<xsd:element name="ZDpUserUnlock">

<xsd:complexType>

<xsd:sequence>

<xsd:element name="PUnlock" type="xsd:string" minOccurs="0"/>

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

</xsd:sequence>

</xsd:complexType>

</xsd:element>

<xsd:element name="ZDpUserUnlockResponse">

<xsd:complexType>

<xsd:sequence>

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

</xsd:sequence>

</xsd:complexType>

</xsd:element>

</xsd:schema>

</wsdl:types>

<wsdl:message name="ZDpUserUnlock">

<wsdl:part name="parameters" element="tns:ZDpUserUnlock"/>

</wsdl:message>

<wsdl:message name="ZDpUserUnlockResponse">

<wsdl:part name="parameter" element="tns:ZDpUserUnlockResponse"/>

</wsdl:message>

<wsdl:portType name="z_unlock_ws">

<wsdl:operation name="ZDpUserUnlock">

<wsdl:input message="tns:ZDpUserUnlock"/>

<wsdl:output message="tns:ZDpUserUnlockResponse"/>

</wsdl:operation>

</wsdl:portType>

</wsdl:definitions>

NB: you can correct the wsdl in a local copy / .wsdl-file, and use that file as your webservice source/URL in the 'Add WebService' window.

Good luck, William.

Former Member
0 Kudos

William,

Thank you for all of your help and valuable knowledge. It's greatly appreciated. I have taken the WSDL you've posted and saved as a local file. I loaded it as a web reference named "SAP" from my local drive. After placing the using directive in the head of my class (using SAP;), I am still unable to get anything to show when trying to reference the "SAP" namespace in one of my class methods. Still says namespace doesn't exist when I compile. I have also changed the "parameters" entry to "parameter", but still no luck. This is quite odd especially since I've gotten other web services to work and you say you've gotten this file to generation everything for you. Could it be the framework version? I am using 3.5.

Once again, thank you for all of your help.

Former Member
0 Kudos

Hi Dennis,

Sorry, due my copy and paste I introduced an inconsistency in the wsdl file. Although the serviceproxy generation went without errors, the net effect was an empty proxy file.

I corrected the inconsistency, now generation gives you a proxy file with code in it.

The inconsistency was here:

<wsdl:definitions

xmlns:tns="urn:sap-com:document:sap:rfc:functions"

xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"

xmlns:xsd="http://www.w3.org/2001/XMLSchema"

xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"

targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style"

xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">

<wsdl:types>

<xsd:schema attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style">

Total correct .wsdl file:

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

<wsdl:definitions

targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style"

xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"

xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"

xmlns:tns="urn:sap-com:document:sap:soap:functions:mc-style" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"

xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<wsdl:types>

<xsd:schema attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style">

<xsd:element name="ZDpUserUnlock">

<xsd:complexType>

<xsd:sequence>

<xsd:element name="PUnlock" type="xsd:string" minOccurs="0"/>

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

</xsd:sequence>

</xsd:complexType>

</xsd:element>

<xsd:element name="ZDpUserUnlockResponse">

<xsd:complexType>

<xsd:sequence>

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

</xsd:sequence>

</xsd:complexType>

</xsd:element>

</xsd:schema>

</wsdl:types>

<wsdl:message name="ZDpUserUnlock">

<wsdl:part name="parameters" element="tns:ZDpUserUnlock"/>

</wsdl:message>

<wsdl:message name="ZDpUserUnlockResponse">

<wsdl:part name="parameter" element="tns:ZDpUserUnlockResponse"/>

</wsdl:message>

<wsdl:portType name="z_unlock_ws">

<wsdl:operation name="ZDpUserUnlock">

<wsdl:input message="tns:ZDpUserUnlock"/>

<wsdl:output message="tns:ZDpUserUnlockResponse"/>

</wsdl:operation>

</wsdl:portType>

</wsdl:definitions>

NB: the generated namespace of the proxy code includes the name of your VS project; thus you must type 'using <ProjectName>.SAP;'

Best regards, William.

Former Member
0 Kudos

Hello,

I appreciate your patience as well as all of your help with this issue, but that file doesn't allow me to use the webservice either. I am tearing my hair out over this. It doesn't in my colleagues V.S. 2005 IDE either.

I do understand that there are imperfections in the WSDL as you have illustrated. This is a problem in SAP. Can somebody shed some light on why this WSDL is unable to be consumed? Why is SAP generating a WSDL file that is incorrect? Once again, I would like to point out that before EP3, I was able to create a webservice from a remote enabled FM and properly consume it from a .Net applicatation by using the "Add Web Reference" functionality of Visual Studio 2005. Now, it will create the .disco and .wsdl files in APP_WebReferences folder, but once I attempt to add the "using <My_WebReference>;" directive, it states that the namespace (The C# namespace, not XML) doesn't exist.

While I have searched through notes upon notes and implemented a few that sounded like they would be the cause of this, I still haven't been able to resolve this issue. Any ideas?

Former Member
0 Kudos

Hi Dennis,

I'm working with VS 2008 (iso VS2005); in there you have the options:

- Add Reference

- Add Web Reference

- Add Service Reference

The latter is new compared to VS2005, and as it names indicates the one to use when referring external services.

When doing that, and pointing to the local .wsdl file we created earlier, entering 'SAP' as namespace; I'll get a proxy class generated. The .NET space of this proxy is '<web application projectname>.SAP'

So, in VS2008 it all goes rather smootly. I cannot easily test in my local environment how it goes with VS2005 since I do no longer have that.

William.

Former Member
0 Kudos

William,

You are absolutely correct. Even after updating my copy of VS2005 to the very latest, I still could not get the WSDL to properly generate a proxy class. After that and reflecting on what you'd said, I downloaded the trial version of VS2008 and installed it. After that point, all seems to be going well. VS2008 will correctly decipher and create a proxy for the standard SAP generated WSDL without any changes being made. Looks like we need to upgrade. Once again, thank you for all of your help.

Former Member
0 Kudos

Hi,

I am trying to consume SAP Webservice wchich converted from FM. I am able to consume, if i add web reference. I need to consume the webservice through code wiothout addidng web referce. so that i can resuse the same code for all webservice consuming.

I am using the following code

System.Net.WebClient client = new System.Net.WebClient();

client.Credentials = new System.Net.NetworkCredential("nagarajan", "yeswecan","");

System.IO.Stream stream = client.OpenRead("http://gurntv021.asian.ad.aricent.com:8000/sap/bc/srt/wsdl/sdef_ZSD_WS_CUSTOMER_CREATE/wsdl11/ws_policy/document?sap-client=230?wsdl");

ServiceDescription description = ServiceDescription.Read(stream);

ServiceDescriptionImporter importer = new ServiceDescriptionImporter();

importer.ProtocolName = "Soap12"; // Use SOAP 1.2.

importer.AddServiceDescription(description, null, null);

Console.WriteLine("Importing service descriptions with associated schemas.",

importer.ServiceDescriptions.Count, importer.Schemas.Count);

importer.Style = ServiceDescriptionImportStyle.Client;

importer.CodeGenerationOptions = System.Xml.Serialization.CodeGenerationOptions.GenerateProperties;

CodeNamespace nmspace = new CodeNamespace();

CodeCompileUnit unit1 = new CodeCompileUnit();

unit1.Namespaces.Add(nmspace);

ServiceDescriptionImportWarnings warning = importer.Import(nmspace, unit1);

if (warning == 0)

{

CodeDomProvider provider1 = CodeDomProvider.CreateProvider("CSharp");

string[] assemblyReferences = new string[2] { "System.Web.Services.dll", "System.Xml.dll" };

CompilerParameters parms = new CompilerParameters(assemblyReferences);

CompilerResults results = provider1.CompileAssemblyFromDom(parms, unit1);

foreach (CompilerError oops in results.Errors)

{

Console.WriteLine("========Compiler error============");

Console.WriteLine(oops.ErrorText);

}

object o = results.CompiledAssembly.CreateInstance("ZWS_SD_Customer_Update", true);

Console.WriteLine(t.InvokeMember("method name", System.Reflection.BindingFlags.InvokeMethod, null, o, a));

}

else

{

Console.WriteLine("Warning: " + warning);

}

Former Member
0 Kudos

Hi,

I am trying to consume SAP Web service which converted from FM. I am able to consume, if i add web reference. I need to consume the web service through code without adding web reference. So that i can reuse the same code for all web service consuming.

I am using the following code

System.Net.WebClient client = new System.Net.WebClient();

client.Credentials = new System.Net.NetworkCredential("username", "password","");

System.IO.Stream stream = client.OpenRead("wsdlurl");

ServiceDescription description = ServiceDescription.Read(stream);

ServiceDescriptionImporter importer = new ServiceDescriptionImporter();

importer.ProtocolName = "Soap12";

importer.AddServiceDescription(description, null, null);

Console.WriteLine("Importing service descriptions with associated schemas.",importer.ServiceDescriptions.Count, importer.Schemas.Count);

importer.Style = ServiceDescriptionImportStyle.Client;

importer.CodeGenerationOptions = System.Xml.Serialization.CodeGenerationOptions.GenerateProperties;

CodeNamespace nmspace = new CodeNamespace();

CodeCompileUnit unit1 = new CodeCompileUnit();

unit1.Namespaces.Add(nmspace);

ServiceDescriptionImportWarnings warning = importer.Import(nmspace, unit1);

if (warning == 0)

{

CodeDomProvider provider1 = CodeDomProvider.CreateProvider("CSharp");

string[] assemblyReferences = new string[2] { "System.Web.Services.dll", "System.Xml.dll" };

CompilerParameters parms = new CompilerParameters(assemblyReferences);

CompilerResults results = provider1.CompileAssemblyFromDom(parms, unit1);

foreach (CompilerError oops in results.Errors)

{

Console.WriteLine("========Compiler error============");

Console.WriteLine(oops.ErrorText);

}

object o = results.CompiledAssembly.CreateInstance("servicename", true);

Console.WriteLine(t.InvokeMember("method name", System.Reflection.BindingFlags.InvokeMethod, null, o, a));

}

else

{

Console.WriteLine("Warning: " + warning);

}

But i am always getting the NoCodeGenerated warning. I tried the above code with .net webservice and it is working perfectly.

Can someone help me on this?

Regards,

Venkat

Former Member
0 Kudos

I am not certain that I am correctly understanding you, but it seems that you want to write one proxy to consume all possible web services. I do not think that this is possible as web services all tend to be different, thus every proxy class generated would be different. Please correct me if I am misunderstanding you.

Former Member
0 Kudos

Hi Dennis,

I am attempting to consume the SAP webservice dynamically. In this case, i have to download the WSDL file dynamically and convert this into assembly at runtime and consume the webservice.

So that i can have a single code and i can consume n number of webservices without writing code. I will configure rest of the details in configuration file.

Regards,

Venkat

Former Member
0 Kudos

HI Venkatesan,

I m Exactly trying to do the same thing which u r trying to do. I wan to consume SAP webservice dynamically in .NET and i m getting same warning as "NoCodeGenerated . and I tried the above code with .net local webservice and it is working perfectly. So, did you manage to over come this issue?? if YES then kindly guide me how??

Answers (0)