I use vS 2012 and .NET 4.0. I use Unit test.
I add Service Reference http://serverxxx:1090/desarrollo/aplicaciones/_vti_bin/lists.asmx
In app.config generate using http://serverxxx:1090/_vti_bin/lists.asmx
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ListsSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxBufferSize="65536" maxReceivedMessageSize="65536"
textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"
messageEncoding="Text">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="ListsSoap1" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://serverxxx:1090/_vti_bin/lists.asmx"
binding="basicHttpBinding"
bindingConfiguration="ListsSoap"
contract="ListWebService.ListsSoap" name="ListsSoap1" />
</client>
</system.serviceModel>
Config ProcDescQA.exe.config
<add key="Listamoss" value="Aplicaciones - Ficha" />
<add key="QueryList" value="<Query><Where><Eq><FieldRef Name='Cargar_x0020_Optimyth'/><Value Type='Boolean'>1</Value></Eq></Where></Query>" />
<add key="PaginacionList" value="10" />
<add key="ViewFields" value="<FieldRef Name='Tecnolog_x00ed_a'/>
 <FieldRef Name='Title'/>
 <FieldRef Name='Descripci_x00f3_n_x0020_corta'/>
 <FieldRef Name='Descripci_x00f3_n_x0020_larga'/>
 <FieldRef Name='Area_x0020_Si_x0026_TIC'/>
 <FieldRef Name='Contacto'/>
 <FieldRef Name='Patrocinador_x0020_negocio'/>
 <FieldRef Name='Roles'/>
 <FieldRef Name='Tipo_x0020_software_x003a_'/>
 <FieldRef Name='Sitio_x0020_web'/>
 <FieldRef Name='Puerto'/>
 <FieldRef Name='Pool'/>
 <FieldRef Name='URL_x0020_acceso_x0020_interno'/>
 <FieldRef Name='URL_x0020_acceso_x0020_externo'/>
 <FieldRef Name='Servidor_x0020_producci_x00f3_n'/>
 <FieldRef Name='URL_x0020_documentaci_x00f3_n'/>
 <FieldRef Name='URL_x0020_PRO'/>
 <FieldRef Name='Recursos'/>
 <FieldRef Name='Ubicaci_x00f3_n_x0020_fuentes'/>
 <FieldRef Name='Cargar_x0020_Optimyth'/>
 <FieldRef Name='Estad_x00ed_sticas_x0020_de_x002'/>
 <FieldRef Name='Comentarios_x0020_calidad'/>
 <FieldRef Name='Monitorizaci_x00f3_n'/>
 " />
<add key="QueryOptions" value="<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns><Paging ListItemCollectionPositionNext=''/>" />
<add key="VistaMoss" value="" />
Unit Test method:
var client = new ListsSoapClient();
client.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
var config = ConfigurationManager.OpenExeConfiguration("ProcDescQA.exe");
var configPath = config.FilePath;
Assert.IsTrue(File.Exists(configPath));
var QueryList = config.AppSettings.Settings["QueryList"].Value;
var ViewFields = config.AppSettings.Settings["ViewFields"].Value;
var QueryOptions = config.AppSettings.Settings["QueryOptions"].Value;
var Listamoss = config.AppSettings.Settings["Listamoss"].Value;
var VistaMoss = config.AppSettings.Settings["VistaMoss"].Value;
var PaginacionList = config.AppSettings.Settings["PaginacionList"].Value;
var xmlDoc = new System.Xml.XmlDocument();
var ndQuery2 = xmlDoc.CreateElement("Query");
if (!String.IsNullOrEmpty(QueryList))
{
ndQuery2.InnerXml = QueryList;
}
var ndViewFields2 = xmlDoc.CreateElement("ViewFields");
if (!String.IsNullOrEmpty(ViewFields))
{
ndViewFields2.InnerXml = ViewFields;
}
var ndQueryOptions2 = xmlDoc.CreateElement("QueryOptions");
if (!String.IsNullOrEmpty(QueryOptions))
{
ndQueryOptions2.InnerXml = QueryOptions;
}
XElement ndQuery = XElement.Parse(ndQuery2.OuterXml);
XElement ndViewFields = XElement.Parse(ndViewFields2.OuterXml);
XElement ndQueryOptions = XElement.Parse(ndQueryOptions2.OuterXml);
try
{
var data = client.GetListItems(Listamoss, VistaMoss, ndQuery, ndViewFields, PaginacionList, ndQueryOptions, null);
}
catch (FaultException ex)
{
Assert.Fail(ex.Message);
}
For me, the signature for GetListItems method is
public System.Xml.Linq.XElement GetListItems(string listName, string viewName, System.Xml.Linq.XElement query, System.Xml.Linq.XElement viewFields, string rowLimit, System.Xml.Linq.XElement queryOptions, string webID)
It uses XElement
, not XmlElement
neither XmlNOde
.
And I get the same error Microsoft.SharePoint.SoapServer.SoapServerException about it.
Any suggestions?
0 commentaires:
Enregistrer un commentaire