I am developing a webservice and a windows application that talk to each
other. They are using a standard VB class library in the background. I am
having problems understanding why I can't sync my namespaces properly.
Example;
My Windows namespace is MyCompany.MyWindowsSpace
My Webservice namespace is MyCompany.MyWebService
My Class Library namespace is MyCompany.MyLibrary
I am using typed objects to send back and forth to my webservice. In my
webservice code-behind page I Have a function that looks like this...
<System.Web.Services.WebService(Namespace:="MyComp any.MyLibrary")_
<System.Web.Services.WebServiceBinding(ConformsTo: =WsiProfiles.BasicProfile1_1)_
<ToolboxItem(False)_
Public Class MyWebService
Inherits System.Web.Services.WebService
<WebMethod()_
Public Function HelloWorld(ByVal MyString As MyCompany.MyLibrary.String)
As MyCompany.MyLibrary.String
Return MyString
End Function
End Class
I register my web reference with my windows application and it asks for a
name. I give it MyWebService as the name. Then, in my code, I use the
following to access the the item and use the webservice...
Protected Friend oWebService As New MyCompany.MyWindowsSpace.MyWebService
Dim oMyString as new MyCompany.MyLibrary.MyString
oMyString.Value = "Hello"
dim oMyStringResult as new MyCompany.MyLibrary.MyString
oMyStringResult = oWebService.HelloWorld(oMyString)
When I compile the code from above, I get the following error message.
Value of type 'MyCompany.MyLibrary.MyString' cannot be converted to
'MyCompany.MyWebService.MyString'. on the actual line that calls HelloWorld.
I found a work-around, but I hate doing it, because everytime I make changes
to the web service, I have to go back to the file mentioned below and make
the changes again. I can select to show all files in my web project, then
navigate under web references to the MyWebService's Reference.map.vb file and
change the following code from...
<System.Web.Services.Protocols.SoapDocumentMethodA ttribute("MyCompany.Library/HelloWorld",
RequestNamespace:="MyCompany.Library",
ResponseNamespace:="MyCompany.Library",
Use:=System.Web.Services.Description.SoapBindingUs e.Literal,
ParameterStyle:=System.Web.Services.Protocols.Soap ParameterStyle.Wrapped) _
Public Function HellowWorld(ByVal oMyString As MyString) As MyString
Dim results() As Object = Me.Invoke("HelloWorld", New Object()
{oMyString})
Return CType(results(0),MyString)
End Function
to...
<System.Web.Services.Protocols.SoapDocumentMethodA ttribute("MyCompany.Library/HelloWorld",
RequestNamespace:="MyCompany.Library",
ResponseNamespace:="MyCompany.Library",
Use:=System.Web.Services.Description.SoapBindingUs e.Literal,
ParameterStyle:=System.Web.Services.Protocols.Soap ParameterStyle.Wrapped) _
Public Function HellowWorld(ByVal oMyString As
MyCompany.MyLibrary.MyString) As MyCompany.MyLibrary.MyString
Dim results() As Object = Me.Invoke("HelloWorld", New Object()
{oMyString})
Return CType(results(0),MyCompany.MyLibrary.MyString)
End Function
It forces my object types and allows me to compile it, because they now
match. Does anyone know how to do this the right way? Thanks for your help.
--
Jon Ebersole
Microsoft Certified Solution Developer