English 中文(简体)
利用权力 壳牌
原标题:Using PowerShell to query CRM 2011 SOAP endpoint

我正试图通过PowerShell和SOAP质疑2011年的CRM。 The following PowerShell script should re- name's full name, but I have no.

$xml = "<?xml version= 1.0  encoding= utf-8 ?>"
$xml += "<soap:Envelope xmlns:soap= http://schemas.xmlsoap.org/soap/envelope/  xmlns:xsi= http://www.w3.org/2001/XMLSchema-instance  xmlns:xsd= http://www.w3.org/2001/XMLSchema >"
$xml += "<soap:Body>"
$xml += "<Retrieve xmlns= http://schemas.microsoft.com/xrm/2011/Contracts/Services >"
$xml += "<entityName>contact</entityName>"
$xml += "<id>12345678-1234-1234-1234-123456789012</id>"
$xml += "<columnSet xmlns:q1= http://schemas.microsoft.com/xrm/2011/Contracts  xsi:type= q1:ColumnSet >"
$xml += "<q1:Attributes>"
$xml += "<q1:Attribute>fullname</q1:Attribute>"
$xml += "<q1:Attribute>telephone1</q1:Attribute>"
$xml += "</q1:Attributes>"
$xml += "</columnSet>"
$xml += "</Retrieve></soap:Body></soap:Envelope>"

$url="http://crmserver.company.com/Organization/XRMServices/2011/Organization.svc/web"
$http_request = New-Object -ComObject Msxml2.XMLHTTP
$http_request.Open( POST , $url, $false)
$http_request.setRequestHeader("SOAPAction",     "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Retrieve");
$http_request.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
$http_request.setRequestHeader("Content-Length", $xml.length);
$http_request.send($xml);
$http_request.responseText

这里的答复是:

$http_request.responseText

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body><RetrieveResponse xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services">
<RetrieveResult xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:Attributes xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
<a:KeyValuePairOfstringanyType>
<b:key>accountid</b:key>
<b:value i:type="c:guid" xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/">12345678-1234-1234-1234-123456789012</b:value>
</a:KeyValuePairOfstringanyType>
</a:Attributes>
<a:EntityState i:nil="true"/><a:FormattedValues xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/>
<a:Id>12345678-1234-1234-1234-123456789012</a:Id><a:LogicalName>account</a:LogicalName>
<a:RelatedEntities xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/>
</RetrieveResult>
</RetrieveResponse>

我不知道我做什么错了。 为什么没有获得“姓名”法的回报?

最佳回答

3. 修改您请求的这一部分内容:

$xml += "<columnSet xmlns:q1= http://schemas.microsoft.com/xrm/2011/Contracts  xsi:type= q1:ColumnSet >"
$xml += "<q1:Columns xmlns:c= http://schemas.microsoft.com/2003/10/Serialization/Arrays >"
$xml += "<c:string>fullname</c:string>"
$xml += "<c:string>telephone1</c:string>"
$xml += "</q1:Columns>"

You can check out some other SOAP examples here: http://code.msdn.microsoft.com/CRM-Online-2011-WebServices-14913a16

问题回答

暂无回答




相关问题
Mutually exclusive powershell parameters

SCENARIO I m writing a cmdlet for Powershell 2.0 using Visual Studio 2008 and .NET 3.5 the cmdlet requires 3 arguments. my intended grammar of the cmdlet is something like this: cmdletname [foo|...

Run a program from PowerShell with timeout

I ll write a script that runs a program and wait for it finished. But if the program is not finished within a specified time I want that the program is killed.

How to transpose data in powershell

I have a file that looks like this: a,1 b,2 c,3 a,4 b,5 c,6 (...repeat 1,000s of lines) How can I transpose it into this? a,b,c 1,2,3 4,5,6 Thanks

Powershell v2 remoting and delegation

I have installed Powershell V2 on 2 machines and run Enable-PsRemoting on both of them. Both machines are Win 2003 R2 and are joined to the same active directory domain and I can successfully run ...

PowerShell -match operator and multiple groups

I have the following log entry that I am processing in PowerShell I m trying to extract all the activity names and durations using the -match operator but I am only getting one match group back. I m ...

热门标签