开发者

wsdl.exe : how to generate proxy code when having same element name in operation?

开发者 https://www.devze.com 2023-01-18 03:45 出处:网络
I have a single WSDL file with many operation. But each of the operation soap body has the same element name , but in different namespaces. e.g operation1 has soap.body.op1:Service

I have a single WSDL file with many operation. But each of the operation soap body has the same element name , but in different namespaces. e.g operation1 has soap.body.op1:Service and operation 2 has soap.body.op2:Service , where op1 and op2 are namespace prefixes.

When i generate my proxy code using wsdl.exe , he generated classes as Service1 and Service2, but if the order is changed in wsdl for service 1 and 2 , or if a new service 3 is added, it becomes difficult to maintain the proxy code.

Is th开发者_开发知识库ere a way to generate the Service1 and Service2 class names based on the wsdl operation , instead of the tag name?

So i would get class names as Operation1 and Operation2 , instead of Service1 and Service2.? Thanks all.


I'm afraid that wsdl.exe has no switches for tweaking the source code that it generates from a WSDL document.

The only way to make it more maintainable is to get a better quality WDSL document. If you are in a position to change this, you can add custom Namespace and Name to your service class by adding more information to the ServiceContract attribute:

namespace op1
{
    [ServiceContract(Name = "MyNicelyNamedService", Namespace = "http://mydomain.com/op1")]
    public class Service
    {
        [OperationContract(Name = "MyAwesomeMethod")]
        public void SomeMethod()
        {
            ...
        }
    }
}

This will generate client code like:

MyNicelyNamedServiceClient client = new MyNicelyNamedServiceClient();
client.MyAwesomeMethod();
client.Close();
0

精彩评论

暂无评论...
验证码 换一张
取 消