|
Hi!
I am trying to grasp the usage of SOAP extensions, and was wondering if someone can help me with this scenario:
I have a command line client which invokes a webservice. In response, the webservice is sending some XML which I would like to validate. I understand that in the case where a client _calls_ a webservice, validation can be done in a SOAP extension for the request that is coming to the webservice. The same thing can be done for a request that is outgoing from the webservice.
In my scenario, the called webservice does need to know (or does not care)about validation, it simply sends out the response. I am not sure how I can validate a response from this webservice to my client (at the client side).
Can I use a SoapExtension here? In which case, how would I configure the client so that when it receives a response, the extension is used?
Thanks in advance!
|
|
|
|
|
There are no configuration sections to configure SOAP extensions on the client. Often times you can attribute your proxy methods with SOAP extension attributes to understand the extensions.
You should take a look at Web Service Enhancements 2.0, OR WSE 2.0, that was just released yesterday. These are classes that implement industry standards (like WS Addressing, WS Security, etc.) that make extensive use of SOAP extensions. That should provide quite a bit of insight, especially if you install the SDK and look over the examples.
Otherwise, you're responsible for parsing the SOAP extensions yourself on your client.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
How to use this DBNull.IConvertible.ToDecimal Method
|
|
|
|
|
IFormatProvider formatter = CultureInfo.InvariantCulture.NumberFormatInfo;
decimal d = ((IConvertable)DBNull.Value).ToDecimal(null); When you see an explicit interface declaration like that, you must first cast it to the interface; then you can call the explicit interface method implementation (or get/set a property or handle an event).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
But I am getting I dont have reference to assembly...
do i need to include any classes..
Thanks for the immediate reply
|
|
|
|
|
You need to reference all necessary assemblies (in this case, mscorlib.dll which is always referenced unless you tell the compiler otherwise) and import the System namespace:
using System;
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am able to do that...
after that also i am unable to convert DBNull value to decimal...
I have a decimal , if nothing is there in that i need to assign a dbnull value to that , but i am not able to do that
Once again thanks for the immediate response
|
|
|
|
|
Because DBNull.IConvertible.ToDecimal always throws an InvalidCastException . But I answered what you asked.
You might want to be more specific about what you're trying to do. If you need to insert a null value for a decimal field in a database, then you actually use DBNull.Value , not the decimal equivalent (which isn't even possible since value types - such as the primative types - can't be null).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Is there anyway i can do that......
|
|
|
|
|
If you use parameterized queryies for example, you could use that as the value:
SqlCommand cmd = sqlConnection1.CreateCommand();
cmd.CommandText = "UPDATE MyTable SET DecimalField = @DecimalField WHERE ID = 1";
SqlParameter decimalField = cmd.Parameters.Add("@DecimalField", SqlDbType.Decimal);
decimalField.Value = myDecimal == 0m ? DBNull.Value : myDecimal;
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi Heath Stewart
Could u let me know the solution for this
I have a web page which contains two frames, I am redirecting the user to login page once session timeout, the problem in both the frames I am getting the login page. could anybody let me know how can i handle so that it will redirect to login page with out any frames....
|
|
|
|
|
This is a common problem with frames, which is why almost all web sites do not use them today. I would recommend designing your site using tables to layout your page with included components like headers, footers, and navigation bars.
If you insist on frames, you will have more problems. Make sure you use the target attribute of the A tab wisely.
As far as deirecting a user to a single login page, this isn't possible using the .NET FCL's authentication modules. You would have to write your own authentication module that takes target frames into account. The ASP.NET authentication modules do not do this.
For more information on how to do this, read about IHttpModule and the existing authentication modules like FormsAuthenticationModule to see how they work, even using ildasm.exe that comes with the .NET SDK (if you know how to read IL) or ".NET Reflector", which you can google for (both a disassembler and decompiler with a nice interface - I currently do not have the link available since I'm on vacation).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi
have a problem
Desc:
I am populating a window from parent window, i will perform some action on the child window and i will click OK button, once i click OK i need to pass a server side created object back to parent window.can you let me know how i can do that?
Thanks in advance
|
|
|
|
|
You can't. Once again, HTTP is simple client request/server response. The best you could do is pull the server from the client to watch for changes using the HTTPXML component or the WebService behavior, both supported only by Internet Explorer (Mozilla has a couple of possibilities as well).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Please can you let me know how can i do that? ii have never worked on HTTPXML COMPONENT
|
|
|
|
|
|
Does anyone know how to call an external program in C#?
Thanks,
Tim Cole
|
|
|
|
|
|
|
Hi,
I have Scripting.DictionaryClass instance passed back to one of my methods from a COM object. I can see that this DictionaryClass instance has 4 items inside it. How can I retrieve the key/value pairs from this object ? I've tried cycling through it via an IEnumerator object but I get an "Invalid cast" exception. I've tried casting to to a System.Collections.Dictionary object but that doesn't seem to work either. I've tried using the Scripting.Dictionary.Items() method but results in an invalid cast also. There are also no getters/setter nor can I index into this object. Anyone have any other solutions ? Thanks in advance...
-Pete
|
|
|
|
|
The Scripting.Dictionary has nothing to do with the .NET FCL, so it doesn't implement IDictionary . It is an RCW (Runtime Callable Wrapper) to a COM object and you must use the COM methods and properties it exposes. The typelib importer (tlbimp.exe) does, however, provide the GetEnumerator which enumerates over the keys, but this is only defined by the DictionaryClass (though Keys() would as well since it's actually an object[] array that you could cast to IEnumerable ).
Take a look at this example code:
using System;
using Interop.Scripting;
public class Test
{
static void Main()
{
IDictionary dict = new DictionaryClass();
Add(dict, "a", 1);
Add(dict, "b", 2);
Add(dict, "c", 3);
object[] keys = (object[])dict.Keys();
for (int i=0; i<keys.Length; i++)
{
object key = keys[i];
object value = dict.get_Item(ref key);
Console.WriteLine("{0}: {1}", key, value);
}
object a = "a";
Console.WriteLine("\na={0}", dict.get_Item(ref a));
}
static void Add(IDictionary dict, object key, object value)
{
dict.Add(ref key, ref value);
}
} The only reason I don't use a foreach loop (uses the IEnumerable implementation) is because the key variable would be read-only, which you can't use with a ref , which is required to call get_Item .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Wow ! Thanks for the quick and very clear reply. You've helped me understand my problem thanks. I just have one quick (and rather silly) question for you. Where can I find the Interop.Scripting assembly ? I can't seem to find it anywhere on my system. I've done a websearch and found a file called "Interop.Scripting.dll" and I managed to add it in to my projects. However when I try to reference it the compiler complains that it can't see it. What am I doing wrong ?
-Pete
|
|
|
|
|
It's the namespace of the interop assembly. I generated the interop assembly using:
tlbimp.exe /out:Interop.Scripting.dll scrrun.dll Chances are that you already have it since you were asking about it. VS.NET creates these automatically when you reference a COM server. If that's not the namespace it generated (though it should be), just change it to whatever is appropriate.
Also note that IDictionary here is Interop.Scripting.IDictionary, Interop.Scripting , not System.Collections.IDictionary, mscorlib . If you have both namespaces imported in your source file, you either need to change the scripting IDictionary to DictionaryClass , fully qualify the type, or use an alias like:
using IDict = Interop.Scripting.IDictionary; Then use IDict instead of IDictionary .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Yep that worked. Thanks a million Heath. I really appreciate all your help. However I have one more quick question. I was looking at your code and you seem to have methods that my version of Interop.Scripting does not. You have a get_Item() method in your DictionaryClass while I don't. I only have the following methods:
Add()
Equals()
Exists()
get_HashVal()
GetEnumerator()
GetHashCode()
GetType()
Items()
Keys()
let_Item
Remove()
RemoveAll()
set_Key()
ToString()
Does this mean I have a different version then you ?
|
|
|
|
|
If you're using IntelliSense, you won't see it. It's defined in the assembly, however. You can't use the Item property because C# can not "call" a property that takes parameters, except for the indexer (which Item is not).
Microsoft MVP, Visual C#
My Articles
|
|
|
|