Using Visual Studio 2005 and C# .NET I was attempting to call methods from the SkillSoft API through their web service and have been running into issues when creating the instance. I started by adding the web service reference to the project (Add Web Reference) and that works fine. Where I get tripped up is in the main .cs where I wish to call the methods I create an instance with the line of code:
SkillSoftWebService.OlsaService service = new SkillSoftWebService.OlsaService();
When I build and run this I get a CS0029 error: InvalidOperationException and it mentioned implicitly converting the queryInclude type to the queryExclude type. I know this question is specific to only those using Skillsoft but I was wondering if anyone had found a work around to this?
Thank you!
As I stated in my last comment, it was actually an issue with the Web Service provided methods so I was able to work around this generic exception by just removing the offending method (since I didn't need it).
Related
Ok, right to the point here is my background story:
I got a vb6 app that will now retrieve data from SAP
A SAP web services was created
I created a DLL using C# that contains the service reference to the web service, makes the call and creates a XML in an ADO Recordset compatible format.
All these has been successfully tested using a Windows Form
There's no problem yet
Now, that being "said", when I integrate that DLL to VB6 I successfully call the DLL's functions. But when I call the function that will return the XML I got the following error:
Virtual Interface Method >WebServiceObject::urn:sap-com:document:sap:soap:functions:mc-style< not supported
And I received an incomplete XML. However when I make the same call from a .NET test web form I got the full XML and everything looks beautiful.
Any hints on this?
Alright,
After a long day looking for this, frustrated with the idea that all my logic looked good I found that the error was on my part. For all of you getting this error please check that methods, parameter, objects in your WSDL matches you endpoint. My problem was that I am setting the end points programmatically using the endpoint's URL and a different end point address was passed from VB6, hence the error that the method called was not supported since it did not belong to that end point.
Good luck all!
I have three projects: My.Business, My.WebSite and My.WebService
I need my logging class to be able to identify when a request is made from the website versus the web service. I used to have the web service running as a separate application underneath the web site, so I'd just use different config files, which worked fine. But I want the web service now to run under the same application.
If I could figure out if the request was coming from My.WebSite or My.WebService, I'd be set, but I'm not sure how to do this.
Assembly.GetExecutingAssembly() returns back My.Business
Assembly.GetEntryAssembly() is null
I could check the StackTrace, but that seems sloppy and how for back would I have to go? Especially because the logging may be triggered by code in My.Business that was originally invoked from one of the other projects.
Since the web service requests end in ".asmx", the following concept works, but it just doesn't feel right.
return HttpContext.Current.Request.Path.IndexOf(".asmx") >= 0 ? "My.WebService" : "My.WebSite";
Thanks!
You should be able to use Assembly.GetCallingAssembly():
return Assembly.GetCallingAssembly().FullName;
This will return the assembly that invoked the current executing method, so you can capture whoever is calling into your My.Business assembly that way.
With that said, I tend to agree with the comment above by Meirion Hughes. You might like to consider passing in any info that is required to your logging class, especially if it is likely to be used across more applications in the future.
this.GetType().Assembly.FullName will give you the name of the assembly name for the current class.
I am building a test-stub for a webservice, implementing the interface retrieved from the production webservice using svcutil. When calling a method on the stub i get the exception;
Object of type
'Sbsys.Services.HostService.DokumentBoks.DKALWSAfsendService.MaterialeType[]'
cannot be converted to type
'Sbsys.Services.HostService.DokumentBoks.DKALWSAfsendService.MaterialeType[]'.
where 'Sbsys.Services.HostService.DokumentBoks' is the namespace of the consuming client, and 'DKALWSAfsendService' is the namespace containing the generated proxy classes for the service.
Any ideas on whats going on?
Bonus info: When using the production service everything works as intended
Solved: I had a suspicion that it might be a versioning problem, and moved my servicereference to an isolated project, containing nothing else. Referenced this from both the consuming client and the webservice stub, hoping that this would solve any problems with building multiple times or whatever. Presto. Problem gone.
Any chance that the wsdl/contract in prod is different from the one you call against ? If the proxy has been generated against the prod and use on another instance of the service with a different contract, you might have that kind of weird message.
Sometime this error occurs because of Generate Serializable Assembly option in Project properties (especially if you are using per-generated serialization assembly using sgen). Try setting this option in Project properties to Off and see if it works. After you turn this option off you will need to per-generate your assembly using sgen. There is some good discussion and background thread in this Q&A for this.
I'm working with an old windows app in visual studio 2005. A webserviced referenced in the original app has 2 functions and when i peak inside the auto-generated reference.cs file I notice a couple of other functions to allow async calls have been geenrated i.e. BeginWhateverFunctionNameIsCalled and EndWhateverFunctionNameIsCalled.
My problem is that I've created a new windows app and added the same web references but the Begin and End functions are not generated in my reference.cs proxy class. Anyone know whats going on?
It is VS2005, and isn't generating the async methods. OK; is it .NET 2.0 or .NET 3.0 (via the VS2005/WCF add-on)?. It looks like "wsdl.exe" (the original) will generate "FooAsync" methods, but WCF ("scvutil.exe") may generate the "BeginFoo" pattern. You might also look to see if you have used WSE*, for example, "wsewsdl2.exe" or "wsewsdl3.exe".
My bets would be of the WCF version. Note also that different frameworks (Silverlight etc) have their own proxy generation classes.
First step would be to check wsdl file returned by web service if those methods are still available on the server.
I have been playing around in PHP with it and got something to work, what i did was:
$client = new SoapClient("http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl");
$fetchedArr = $client->GetCityForecastByZIP(array("ZIP" => "10451")); //get the weather in the bronx YO!
And now i would like my application i WPF/C# to do the same. What is the equivalent in c#?
The simplest way is to use VS and add a web reference. This automatically creates the stub for you
You can use the WSDL tool to generate a C# file which will contain the necessary types and members to talk to the web service or you could add a Web Service reference. See here for more details.
If your preferred approach is to control the generated code, it's best to use the more recent SvcUtil.exe in place of Wsdl.exe.
See also WCF proxy generation: svcutil.exe vs wsdl.exe
Adding web service reference to your project n making a call to the service exposed methods is your best bet . It does the trick n you're out of the hassle of creating SOAPs manually
You can use the "wsdl.exe" command from the .NET SDK to generate the wrapper classes if you don't want or like to use Visual Studio.
see:
http://msdn.microsoft.com/en-us/library/7h3ystb6%28VS.80%29.aspx