XML Web Services Craziness

Posts   
 
    
Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 25-Mar-2005 19:01:01   

I have a client, a business object (named UserInfo), and a web service. Both the web service and the client use the same business object.

In my client, I want to be able to write code like this:


  LogError svc = new LogError();
  ErrorInfo info = new ErrorInfo();
  info.UserInfo = Globals.Instance.UserInfo
  svc.LogException(info);

But, when the proxy is generated from the wsdl UserInfo is treated as a different object because it has a different namespace in the proxy definition, forcing me to write code like this:


                LogError svc = new LogError();
                ErrorInfo info = new ErrorInfo();
                if (info.UserInfo == null)
                {
                    info.UserInfo = new UserInfo();
                }
                info.UserInfo.Company = Globals.Instance.UserInfo.Company;
                info.UserInfo.Email = Globals.Instance.UserInfo.Email;
                info.UserInfo.UserName = Globals.Instance.UserInfo.UserName;
                info.ExceptionDetails = richTextBox1.Text;

                svc.Credentials = System.Net.CredentialCache.DefaultCredentials;
                svc.LogException(info);

I could go into the generated proxy and change the namespace of UserInfo to be the same namespace as defined in the BusinessObject assembly, but that seems like a hack.

Can I do something in the WSDL, or web method, or the definition of the ErrorInfo object class defnition to force the WSDL to generate the proper namespace for the UserInfo object?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39801
Joined: 17-Aug-2003
# Posted on: 26-Mar-2005 11:05:55   

Altering the generated stub class is the only way in this, I'm afraid. Google on the situation and you'll find (in google groups) several posts from Microsoft employees suggesting to alter the generated code...

I don't know if they work in your situation, but you could check out the tools Christian Weyer wrote at thinktecture, which offer a code generator for stubs for webservices: http://www.thinktecture.com/Resources/default.html

Frans Bouma | Lead developer LLBLGen Pro