Home » Category » Microsoft Visual Studio

Microsoft Visual Studio: Service Moniker for COM Clients using WSDL and not mex.

100| Thu, 20 Dec 2007 22:18:00 GMT| cicorias| Comments (4)

Any chance someone can post what the Xml string/stream needs to look like in order to use the wsdl parameter for COM clients using the Service Moniker and WSDL?

Not the MEX (WS-Mex) method, the WSDL method.

From Andy Milligan's PDC presentation, there was a slide (I don't have the demo's) with the following:

wsdlStr = "<xml ... " << -==== What's in the string?
Set monikerProxy =
GetObject("service:address=http://myServer/TestService/,
wsdl='" & wsdlStr & "',
binding=wsProfileBinding,
contract=IWarehouse")
currStock = monikerProxy.GetStockLevel("ID:223")


what's in that "wsdlStr" string/stream?

I have Mex working no problem as follows:

Option Explicit Dim quoteProxy, moniker, result moniker="service:mexAddress=http://localhost/QuickReturnsQuotes/service.svc/mex, " moniker=moniker + "address=http://localhost/QuickReturnsQuotes/service.svc," moniker=moniker + "contract=IQuoteService, contractNamespace=http://PracticalWcf/QuoteService, " moniker=moniker + "binding=WSHttpBinding_IQuoteService, bindingNamespace=http://tempuri.org/" Set quoteProxy = GetObject(moniker) result = quoteProxy.GetQuote("MSFT") WScript.Echo "MSFT's price is " + CStr(resul 

Keywords & Tags: service, moniker, com, clients, wsdl, mex, microsoft, visual studio

URL: http://www.cooldevelopers.com/visual-studio/83188/
 
«« Prev - Next »» 4 helpful answers below.

The moniker always requires a definition of the contract that you wish to use. This is true whether you are using the moniker with a strongly typed svcutil generated proxy (i.e a typelib contract), or with a WSDL contract definition or with a WS-MetadataExchange retrieved contract.

In this case, the parameter wsdlStr would be set to the complete WSDL contract for the service as a string. This would either be defined within your script, for an entirely self contained scenario or may be read in from a file or well know location. The tasks of loading the WSDL into a string parameter is out of scope of the moniker.

I will follow up with a simple client, contract and server example.

Thanks,

Andy Milligan.

andymilligan | Mon, 10 Sep 2007 17:00:00 GMT |

I've taken the string response from querying my service endpoints WSDL document
i.e. http://localhost/MyService/service.svc?wsdl

Then, stored that in a document, and using File I/O read it into a var and make the moniker look as so:

wsdl = ReadWsdlFromFile ( "service.svc.wsdl" )
moniker="service:wsdl=" & wsdl & ", "
moniker=moniker + "address=http://localhost/QuickReturnsQuotes/service.svc,"
moniker=moniker + "contract=IQuoteService, contractNamespace=http://PracticalWcf/QuoteService, "
moniker=moniker + "binding=WSHttpBinding_IQuoteService, bindingNamespace=http://tempuri.org/"

Now, running the script, I receive the following error:
ScriptClientWsdl.vbs(35, 1) System.ServiceModel: Import failed on W
sdl with Error: Element message named IQuoteService from namespace http://tempuri.org/ is missing..

Obviously I have malformed WSDL or missing imports. So, I manually insert the wsdl:imports into the schema and I continue to get the following error:
ScriptClientWsdl.vbs(35, 1) System.ServiceModel: Import failed on W
sdl with Error: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerialize
rMessageContractConverter
Error: Schema with target namespace http://tempuri.org/ could not be found.
.

I'll gladly upload the sample project - it's a small tester solution.

cicorias | Mon, 10 Sep 2007 17:01:00 GMT |

Looks like the Wsdl deserialization has an issue with a service that has a namespace other than http://tempuri.org/

If I remove the attribute from the Service class:
[ServiceContract(
//Namespace = "http://PracticalWcf/QuoteService"
)]

Regenerate the proxy and change the moniker as follows:

wsdl = ReadWsdlFromFile ( "TempUri.service.svc.wsdl" )
moniker="service:wsdl=" & wsdl & ", "
moniker=moniker + "address=http://localhost/QuickReturnsQuotes/service.svc,"
moniker=moniker + "contract=IQuoteService, contractNamespace=http://tempuri.org/, "
moniker=moniker + "binding=WSHttpBinding_IQuoteService, bindingNamespace=http://tempuri.org/"

Now, if I have the Service class with the Namespace attribute set to something else, I have a failure:

I've tried the following for Wsdl dynamic proxy generation and it fails:
wsdl = ReadWsdlFromFile ( "service.svc.wsdl" )
moniker="service:wsdl=" & wsdl & ", "
moniker=moniker + "address=http://localhost/QuickReturnsQuotes/service.svc,"
moniker=moniker + "contract=IQuoteService, contractNamespace=http://PracticalWcf/QuoteService, "
moniker=moniker + "binding=WSHttpBinding_IQuoteService, bindingNamespace=http://PracticalWcf/QuoteService"

and also this:
wsdl = ReadWsdlFromFile ( "service.svc.wsdl" )
moniker="service:wsdl=" & wsdl & ", "
moniker=moniker + "address=http://localhost/QuickReturnsQuotes/service.svc,"
moniker=moniker + "contract=IQuoteService, contractNamespace=http://PracticalWcf/QuoteService, "
moniker=moniker + "binding=WSHttpBinding_IQuoteService, bindingNamespace=http://tempuri.org/"

However, under Mex the following works perfectly:

moniker="service:mexAddress=http://localhost/QuickReturnsQuotes/service.svc/mex, "
moniker=moniker + "address=http://localhost/QuickReturnsQuotes/service.svc, "
moniker=moniker + "contract=IQuoteService, "
moniker=moniker + "contractNamespace=http://PracticalWcf/QuoteService, "
moniker=moniker + "binding=WSHttpBinding_IQuoteService, "
moniker=moniker + "bindingNamespace=http://tempuri.org/"

cicorias | Mon, 10 Sep 2007 17:03:00 GMT |

Looks like it's been fixed:http://lab.msdn.microsoft.com/ProductFeedback/viewfeedback.aspx?feedbackid=fb81e779-b736-419e-a91c-36f4e35c7bad

Still not 100% sure the issue was understood.

The real issue is if I adorn my service contract (Interface) with the Namespace attribute, the WSDL functionality wouldn't work at all.

cicorias | Mon, 10 Sep 2007 17:04:00 GMT |

Microsoft Visual Studio Hot Answers

Microsoft Visual Studio New questions

Microsoft Visual Studio Related Categories