I have the following service interface that I have imported using the Visual Studio tool (it is a WCF Web Service).
But when I try to consume the service AuthenticateJAAS (execute the web service), I get the following error:
InvalidOperationException: The top XML element 'parameters' from namespace '' references distinct types XAFProject.Module.WS.MCWFUsers.mcwfUsersGetUserGroupsIn and XAFProject.Module.WS.MCWFUsers.mcwfUsersAuthenticateJAASIn. Use XML attributes to specify another XML name or namespace for the element or types.
I cannot change the namespace or the element name 'parameters', as it is from a WSDL that cannot be changed (third party). When I remove the class GetUserGroupsRequest and related content from the Reference.cs, I can consume the web service AuthenticateJAAS without problems. The generated XML is:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<AuthenticateJAAS xmlns="http://services.senior.com.br">
<user xmlns=""/>
<password xmlns=""/>
<encryption xmlns="">0</encryption>
<parameters xmlns="">
<flowInstanceID xsi:nil="true"/>
<flowName xsi:nil="true"/>
<pmUserName>******</pmUserName>
<pmUserPassword>******</pmUserPassword>
</parameters>
</AuthenticateJAAS>
</s:Body>
</s:Envelope>
Is there a way to use both methods/services (AuthenticateJAAS + GetUserGroupsRequest) without any error? I was thinking that maybe, if I use namespace prefixes, I could manage to use both services, I think.
Here is the part of the code that I initialize the client and execute the service:
sapiens_SyncMCWFUsersClient mCWFUsersClient = new sapiens_SyncMCWFUsersClient();
mcwfUsersAuthenticateJAASIn parameters = new mcwfUsersAuthenticateJAASIn();
parametrosEntrada.pmUserName = "******";
parametrosEntrada.pmUserPassword = "******";
parametrosEntrada.pmEncrypted = 0;
AuthenticateJAASRequest request = new AuthenticateJAASRequest("", "", 0, parameters);
AuthenticateJAASResponse response = mCWFUsersClient.AuthenticateJAAS(request);
So far, I solved my problem by doing the following in the Reference.cs file. [System.ServiceModel.MessageBodyMemberAttribute(Namespace= "", Order=3, Name = "parameters")]
. Then, I changed the field name to anything but "parameter". In this case public MCWFUsers.mcwfUsersGetUserGroupsIn parametersGetUserGroups;
That means that this will not reference distinct types inside cs file.
I changed this:
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.3")]
[System.ServiceModel.MessageContractAttribute(WrapperName="GetUserGroups", WrapperNamespace="http://services.senior.com.br", IsWrapped=true)]
public partial class GetUserGroupsRequest
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace= "", Order=0)]
public string user;
[System.ServiceModel.MessageBodyMemberAttribute(Namespace= "", Order=1)]
public string password;
[System.ServiceModel.MessageBodyMemberAttribute(Namespace= "", Order=2)]
public int encryption;
[System.ServiceModel.MessageBodyMemberAttribute(Namespace= "", Order=3)]
public MCWFUsers.mcwfUsersGetUserGroupsIn parameters;
public GetUserGroupsRequest()
{
}
public GetUserGroupsRequest(string user, string password, int encryption, MCWFUsers.mcwfUsersGetUserGroupsIn parameters)
{
this.user = user;
this.password = password;
this.encryption = encryption;
this.parameters = parameters;
}
}
to this
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.3")]
[System.ServiceModel.MessageContractAttribute(WrapperName="GetUserGroups", WrapperNamespace="http://services.senior.com.br", IsWrapped=true)]
public partial class GetUserGroupsRequest
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace= "", Order=0)]
public string user;
[System.ServiceModel.MessageBodyMemberAttribute(Namespace= "", Order=1)]
public string password;
[System.ServiceModel.MessageBodyMemberAttribute(Namespace= "", Order=2)]
public int encryption;
[System.ServiceModel.MessageBodyMemberAttribute(Namespace= "", Order=3, Name = "parameters")]
public MCWFUsers.mcwfUsersGetUserGroupsIn parametersGetUserGroups;
public GetUserGroupsRequest()
{
}
public GetUserGroupsRequest(string user, string password, int encryption, MCWFUsers.mcwfUsersGetUserGroupsIn parameters)
{
this.user = user;
this.password = password;
this.encryption = encryption;
this.parametersGetUserGroups = parameters;
}
}
Edit: Nope, that didn't solve it, unfortunately. I will keep trying.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.