Web Service Clients without Web References

D

Doug Holland

I'm trying to write web service proxy class such as that autogenerated by
adding a Web Service (e.g. Reference.cs) which inherits from
SoapHttpClientProtocol.

Even when my class is a near duplicate of that found within Reference.cs
with the only differences being that I don't use fully qualified namespaces I
have a problem calling a HelloWorld WebMethod.

Using the autogenerated class the following code:

object[] results = this.Invoke("HelloWorld", new object[0]);
return ((string)(results[0]));

Successfully returns "Hello World" in the first element of the object array.

Using my class which also contains:

object[] results = this.Invoke("HelloWorld", new object[0]);
return ((string)(results[0]));

and successfully steps into the Web Method using the debugger ... returns
null in the first element of the object array.

In my proxy component I don't have the other files generated by a Web
Reference such as the .disco, .wsdl, and .map files, is this my problem?

Thanks in advance

Doug Holland

PS: The motivation for my own proxy object is that the web service to talk
to would be set in a database and it may well actually talk to more than one
web servcie. Because the webservice isn't known at compile time, just the
'interface', I can't do that with a standard Web Reference which fixes the
URL.
 
D

Dan Rogers

Hi Doug,

You need to match the namespace expectations in the proxy code so that the
namespace the client looks for matches the namespace of the data on the
wire. The generated proxy code which you didn't show (and possibly take
into account) is the Xml*Attribute markup that accompanies the code in the
generated proxy.

Namespace is very important in deserializing. What is happening is an
element with a specific namespace is encountered on the wire, but no
corresponding members in the calling code are marked as being the match for
the data received. You cannot successfully say that the element names
match so why doesn't it just work. In XML, the namespace is an intricate
part of the data contract. If you add the attributes that make the
generated code work, you will find that the members serialize back
correctly.

I hope this helps,

Dan Rogers
Microsoft Corporation
--------------------
Thread-Topic: Web Service Clients without Web References
thread-index: AcTRnd2NOl7HgnovQvSEcXOvSRKC3g==
X-WBNR-Posting-Host: 192.55.52.4
From: =?Utf-8?B?RG91ZyBIb2xsYW5k?= <[email protected]>
Subject: Web Service Clients without Web References
Date: Tue, 23 Nov 2004 12:49:03 -0800
Lines: 35
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.aspnet.webservices:26775
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices

I'm trying to write web service proxy class such as that autogenerated by
adding a Web Service (e.g. Reference.cs) which inherits from
SoapHttpClientProtocol.

Even when my class is a near duplicate of that found within Reference.cs
with the only differences being that I don't use fully qualified namespaces I
have a problem calling a HelloWorld WebMethod.

Using the autogenerated class the following code:

object[] results = this.Invoke("HelloWorld", new object[0]);
return ((string)(results[0]));

Successfully returns "Hello World" in the first element of the object array.

Using my class which also contains:

object[] results = this.Invoke("HelloWorld", new object[0]);
return ((string)(results[0]));

and successfully steps into the Web Method using the debugger ... returns
null in the first element of the object array.

In my proxy component I don't have the other files generated by a Web
Reference such as the .disco, .wsdl, and .map files, is this my problem?

Thanks in advance

Doug Holland

PS: The motivation for my own proxy object is that the web service to talk
to would be set in a database and it may well actually talk to more than one
web servcie. Because the webservice isn't known at compile time, just the
'interface', I can't do that with a standard Web Reference which fixes the
URL.
 
D

Doug Holland

I actually had the exact same SoapDocumentMethodAttribute adorning my
HelloWorld method (shown below), and the request and response namespaces are
the same as in the autogenerated class ... I omitted them in the last e-mail
to enhance readability.

Is the SoapDocumentMethodAttribute attribute properties what you were
refering to when discussing namespaces (e.g. http://tempuri.org)?

As stated in the original e-mail ... essentially the only difference is that
I'm omitting the fully qualified namespaces and ommitting 'Attribute' off the
name of the custom attributes.


[SoapDocumentMethod("http://tempuri.org/HelloWorld",
RequestNamespace="http://tempuri.org/",
ResponseNamespace="http://tempuri.org/", Use=SoapBindingUse.Literal,
ParameterStyle=SoapParameterStyle.Wrapped)]
public string HelloWorld()
{
object[] results = this.Invoke("HelloWorld", new object[0]);

return results[0] as string;
}

Thanks in advance

Doug Holland


Dan Rogers said:
Hi Doug,

You need to match the namespace expectations in the proxy code so that the
namespace the client looks for matches the namespace of the data on the
wire. The generated proxy code which you didn't show (and possibly take
into account) is the Xml*Attribute markup that accompanies the code in the
generated proxy.

Namespace is very important in deserializing. What is happening is an
element with a specific namespace is encountered on the wire, but no
corresponding members in the calling code are marked as being the match for
the data received. You cannot successfully say that the element names
match so why doesn't it just work. In XML, the namespace is an intricate
part of the data contract. If you add the attributes that make the
generated code work, you will find that the members serialize back
correctly.

I hope this helps,

Dan Rogers
Microsoft Corporation
--------------------
Thread-Topic: Web Service Clients without Web References
thread-index: AcTRnd2NOl7HgnovQvSEcXOvSRKC3g==
X-WBNR-Posting-Host: 192.55.52.4
From: =?Utf-8?B?RG91ZyBIb2xsYW5k?= <[email protected]>
Subject: Web Service Clients without Web References
Date: Tue, 23 Nov 2004 12:49:03 -0800
Lines: 35
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.aspnet.webservices:26775
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices

I'm trying to write web service proxy class such as that autogenerated by
adding a Web Service (e.g. Reference.cs) which inherits from
SoapHttpClientProtocol.

Even when my class is a near duplicate of that found within Reference.cs
with the only differences being that I don't use fully qualified namespaces I
have a problem calling a HelloWorld WebMethod.

Using the autogenerated class the following code:

object[] results = this.Invoke("HelloWorld", new object[0]);
return ((string)(results[0]));

Successfully returns "Hello World" in the first element of the object array.

Using my class which also contains:

object[] results = this.Invoke("HelloWorld", new object[0]);
return ((string)(results[0]));

and successfully steps into the Web Method using the debugger ... returns
null in the first element of the object array.

In my proxy component I don't have the other files generated by a Web
Reference such as the .disco, .wsdl, and .map files, is this my problem?

Thanks in advance

Doug Holland

PS: The motivation for my own proxy object is that the web service to talk
to would be set in a database and it may well actually talk to more than one
web servcie. Because the webservice isn't known at compile time, just the
'interface', I can't do that with a standard Web Reference which fixes the
URL.
 
D

Doug Holland

It appears I was missing the final '\' in the namespace
"http://tempuri.org/", I didn't notice the difference until about 5 mins ago.

Thanks

Doug

Doug Holland said:
I actually had the exact same SoapDocumentMethodAttribute adorning my
HelloWorld method (shown below), and the request and response namespaces are
the same as in the autogenerated class ... I omitted them in the last e-mail
to enhance readability.

Is the SoapDocumentMethodAttribute attribute properties what you were
refering to when discussing namespaces (e.g. http://tempuri.org)?

As stated in the original e-mail ... essentially the only difference is that
I'm omitting the fully qualified namespaces and ommitting 'Attribute' off the
name of the custom attributes.


[SoapDocumentMethod("http://tempuri.org/HelloWorld",
RequestNamespace="http://tempuri.org/",
ResponseNamespace="http://tempuri.org/", Use=SoapBindingUse.Literal,
ParameterStyle=SoapParameterStyle.Wrapped)]
public string HelloWorld()
{
object[] results = this.Invoke("HelloWorld", new object[0]);

return results[0] as string;
}

Thanks in advance

Doug Holland


Dan Rogers said:
Hi Doug,

You need to match the namespace expectations in the proxy code so that the
namespace the client looks for matches the namespace of the data on the
wire. The generated proxy code which you didn't show (and possibly take
into account) is the Xml*Attribute markup that accompanies the code in the
generated proxy.

Namespace is very important in deserializing. What is happening is an
element with a specific namespace is encountered on the wire, but no
corresponding members in the calling code are marked as being the match for
the data received. You cannot successfully say that the element names
match so why doesn't it just work. In XML, the namespace is an intricate
part of the data contract. If you add the attributes that make the
generated code work, you will find that the members serialize back
correctly.

I hope this helps,

Dan Rogers
Microsoft Corporation
--------------------
Thread-Topic: Web Service Clients without Web References
thread-index: AcTRnd2NOl7HgnovQvSEcXOvSRKC3g==
X-WBNR-Posting-Host: 192.55.52.4
From: =?Utf-8?B?RG91ZyBIb2xsYW5k?= <[email protected]>
Subject: Web Service Clients without Web References
Date: Tue, 23 Nov 2004 12:49:03 -0800
Lines: 35
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.aspnet.webservices:26775
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices

I'm trying to write web service proxy class such as that autogenerated by
adding a Web Service (e.g. Reference.cs) which inherits from
SoapHttpClientProtocol.

Even when my class is a near duplicate of that found within Reference.cs
with the only differences being that I don't use fully qualified namespaces I
have a problem calling a HelloWorld WebMethod.

Using the autogenerated class the following code:

object[] results = this.Invoke("HelloWorld", new object[0]);
return ((string)(results[0]));

Successfully returns "Hello World" in the first element of the object array.

Using my class which also contains:

object[] results = this.Invoke("HelloWorld", new object[0]);
return ((string)(results[0]));

and successfully steps into the Web Method using the debugger ... returns
null in the first element of the object array.

In my proxy component I don't have the other files generated by a Web
Reference such as the .disco, .wsdl, and .map files, is this my problem?

Thanks in advance

Doug Holland

PS: The motivation for my own proxy object is that the web service to talk
to would be set in a database and it may well actually talk to more than one
web servcie. Because the webservice isn't known at compile time, just the
'interface', I can't do that with a standard Web Reference which fixes the
URL.
 
D

Dan Rogers

Hi Doug,

Great. Yes, the namespace matching exactly is critical to successful
serialization.

Glad you got it working

Dan
--------------------
Thread-Topic: Web Service Clients without Web References
thread-index: AcTRuT7fU2ny3POpTu6e+JyjmiLctg==
X-WBNR-Posting-Host: 192.55.52.4
From: =?Utf-8?B?RG91ZyBIb2xsYW5k?= <[email protected]>
References: <[email protected]>
Subject: RE: Web Service Clients without Web References
Date: Tue, 23 Nov 2004 16:05:02 -0800
Lines: 127
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.aspnet.webservices:26786
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices

It appears I was missing the final '\' in the namespace
"http://tempuri.org/", I didn't notice the difference until about 5 mins ago.

Thanks

Doug

Doug Holland said:
I actually had the exact same SoapDocumentMethodAttribute adorning my
HelloWorld method (shown below), and the request and response namespaces are
the same as in the autogenerated class ... I omitted them in the last e-mail
to enhance readability.

Is the SoapDocumentMethodAttribute attribute properties what you were
refering to when discussing namespaces (e.g. http://tempuri.org)?

As stated in the original e-mail ... essentially the only difference is that
I'm omitting the fully qualified namespaces and ommitting 'Attribute' off the
name of the custom attributes.


[SoapDocumentMethod("http://tempuri.org/HelloWorld",
RequestNamespace="http://tempuri.org/",
ResponseNamespace="http://tempuri.org/", Use=SoapBindingUse.Literal,
ParameterStyle=SoapParameterStyle.Wrapped)]
public string HelloWorld()
{
object[] results = this.Invoke("HelloWorld", new object[0]);

return results[0] as string;
}

Thanks in advance

Doug Holland


Dan Rogers said:
Hi Doug,

You need to match the namespace expectations in the proxy code so that the
namespace the client looks for matches the namespace of the data on the
wire. The generated proxy code which you didn't show (and possibly take
into account) is the Xml*Attribute markup that accompanies the code in the
generated proxy.

Namespace is very important in deserializing. What is happening is an
element with a specific namespace is encountered on the wire, but no
corresponding members in the calling code are marked as being the match for
the data received. You cannot successfully say that the element names
match so why doesn't it just work. In XML, the namespace is an intricate
part of the data contract. If you add the attributes that make the
generated code work, you will find that the members serialize back
correctly.

I hope this helps,

Dan Rogers
Microsoft Corporation
--------------------
Thread-Topic: Web Service Clients without Web References
thread-index: AcTRnd2NOl7HgnovQvSEcXOvSRKC3g==
X-WBNR-Posting-Host: 192.55.52.4
From: =?Utf-8?B?RG91ZyBIb2xsYW5k?=
Subject: Web Service Clients without Web References
Date: Tue, 23 Nov 2004 12:49:03 -0800
Lines: 35
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.aspnet.webservices:26775
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices

I'm trying to write web service proxy class such as that autogenerated by
adding a Web Service (e.g. Reference.cs) which inherits from
SoapHttpClientProtocol.

Even when my class is a near duplicate of that found within Reference.cs
with the only differences being that I don't use fully qualified
namespaces I
have a problem calling a HelloWorld WebMethod.

Using the autogenerated class the following code:

object[] results = this.Invoke("HelloWorld", new object[0]);
return ((string)(results[0]));

Successfully returns "Hello World" in the first element of the object
array.

Using my class which also contains:

object[] results = this.Invoke("HelloWorld", new object[0]);
return ((string)(results[0]));

and successfully steps into the Web Method using the debugger ... returns
null in the first element of the object array.

In my proxy component I don't have the other files generated by a Web
Reference such as the .disco, .wsdl, and .map files, is this my problem?

Thanks in advance

Doug Holland

PS: The motivation for my own proxy object is that the web service to talk
to would be set in a database and it may well actually talk to more than
one
web servcie. Because the webservice isn't known at compile time, just the
'interface', I can't do that with a standard Web Reference which fixes the
URL.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top