私は多くの投稿があり、多くを読んでいることを知っていますが、私のコードで何かが見当たりません。SOAPを返す返信
シスコの電話システムから石鹸リターンを解析しようとしていますが、古いバージョンで作業していましたが、今では必要なデータを抽出できません。
String xmlText = File.ReadAllText(@"c:\temp\IPAddress.xml");
XmlDocument doc = new XmlDocument();
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
nsmgr.AddNamespace("ns1", "http://schemas.cisco.com/ast/soap/");
doc.LoadXml(xmlText);
XmlNodeList items = doc.SelectNodes("/soapenv:Envelope/soapenv:Body/ns1:selectCmDeviceResponse/ns1:selectCmDeviceReturn/ns1:SelectCmDeviceResult/ns1:CmNodes/ns1:item/ns1:CmDevices/ns1:item", nsmgr);
Console.WriteLine(doc.InnerText.ToString());
foreach (XmlNode item in items)
{
string Name = GetNodeValue(item, "Name");
string Description = GetNodeValue(item, "ns1:Description");
string IpAddress = GetNodeValue(item, "ns1:IpAddress/ns1:item/ns1:IP");
string DirNumber = GetNodeValue(item, "ns1:DirNumber");
string Class = GetNodeValue(item, "ns1:DeviceClass");
string Model = GetNodeValue(item, "ns1:Model");
string Product = GetNodeValue(item, "ns1:Product");
UpdateInfo(Name, IpAddress);
}
}
Here is a snip of the XML:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns1:selectCmDeviceResponse xmlns:ns1="http://schemas.cisco.com/ast/soap">
<ns1:selectCmDeviceReturn>
<ns1:SelectCmDeviceResult>
<ns1:TotalDevicesFound>4</ns1:TotalDevicesFound>
<ns1:CmNodes>
<ns1:item>
<ns1:ReturnCode>Ok</ns1:ReturnCode>
<ns1:Name>10.0.5.125</ns1:Name>
<ns1:NoChange>false</ns1:NoChange>
<ns1:CmDevices>
<ns1:item>
<ns1:Name>SEP1CE6C7729944</ns1:Name>
<ns1:DirNumber>4402-UnRegistered</ns1:DirNumber>
<ns1:DeviceClass>Phone</ns1:DeviceClass>
<ns1:Model>435</ns1:Model>
<ns1:Product>334</ns1:Product>
<ns1:BoxProduct>0</ns1:BoxProduct>
<ns1:Httpd>Yes</ns1:Httpd>
<ns1:RegistrationAttempts>0</ns1:RegistrationAttempts>
<ns1:IsCtiControllable>true</ns1:IsCtiControllable>
<ns1:LoginUserId>earlene.gonzalez</ns1:LoginUserId>
<ns1:Status>UnRegistered</ns1:Status>
<ns1:StatusReason>8</ns1:StatusReason>
<ns1:PerfMonObject>2</ns1:PerfMonObject>
<ns1:DChannel>0</ns1:DChannel>
<ns1:Description>105_GRN_LO-PH</ns1:Description>
<ns1:H323Trunk>
<ns1:ConfigName xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:TechPrefix xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:Zone xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:RemoteCmServer1 xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:RemoteCmServer2 xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:RemoteCmServer3 xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:AltGkList xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:ActiveGk xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:CallSignalAddr xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:RasAddr xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</ns1:H323Trunk>
<ns1:TimeStamp>1494272299</ns1:TimeStamp>
<ns1:Protocol>SCCP</ns1:Protocol>
<ns1:NumOfLines>1</ns1:NumOfLines>
<ns1:LinesStatus>
<ns1:item>
<ns1:DirectoryNumber>4402</ns1:DirectoryNumber>
<ns1:Status>UnRegistered</ns1:Status>
</ns1:item>
</ns1:LinesStatus>
<ns1:ActiveLoadID>SCCP45.9-4-2SR2-2S</ns1:ActiveLoadID>
<ns1:InactiveLoadID xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:DownloadStatus>Unknown</ns1:DownloadStatus>
<ns1:DownloadFailureReason xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:DownloadServer xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:IPAddress>
<ns1:item>
<ns1:IP>10.105.2.55</ns1:IP>
<ns1:IPAddrType>ipv4</ns1:IPAddrType>
<ns1:Attribute>AdministrativeAndSignaling</ns1:Attribute>
</ns1:item>
</ns1:IPAddress>
</ns1:item>
<ns1:item>
<ns1:Name>SEP1CE6C772F3FB</ns1:Name>
<ns1:DirNumber xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:DeviceClass>Phone</ns1:DeviceClass>
<ns1:Model>435</ns1:Model>
<ns1:Product>334</ns1:Product>
<ns1:BoxProduct>0</ns1:BoxProduct>
<ns1:Httpd>Yes</ns1:Httpd>
<ns1:RegistrationAttempts>1</ns1:RegistrationAttempts>
<ns1:IsCtiControllable>true</ns1:IsCtiControllable>
<ns1:LoginUserId xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:Status>Rejected</ns1:Status>
<ns1:StatusReason>27</ns1:StatusReason>
<ns1:PerfMonObject>0</ns1:PerfMonObject>
<ns1:DChannel>0</ns1:DChannel>
<ns1:Description xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:H323Trunk>
<ns1:ConfigName xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:TechPrefix xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:Zone xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:RemoteCmServer1 xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:RemoteCmServer2 xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:RemoteCmServer3 xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:AltGkList xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:ActiveGk xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:CallSignalAddr xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:RasAddr xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</ns1:H323Trunk>
<ns1:TimeStamp>1494335117</ns1:TimeStamp>
<ns1:Protocol>SCCP</ns1:Protocol>
<ns1:NumOfLines>0</ns1:NumOfLines>
<ns1:LinesStatus/>
<ns1:ActiveLoadID xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:InactiveLoadID xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:DownloadStatus>Unknown</ns1:DownloadStatus>
<ns1:DownloadFailureReason xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:DownloadServer xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:IPAddress>
<ns1:item>
<ns1:IP>10.106.0.104</ns1:IP>
<ns1:IPAddrType>ipv4</ns1:IPAddrType>
<ns1:Attribute>AdministrativeAndSignaling</ns1:Attribute>
</ns1:item>
</ns1:IPAddress>
</ns1:item>
</ns1:CmDevices>
</ns1:item>
<ns1:item>
<ns1:ReturnCode>Ok</ns1:ReturnCode>
<ns1:Name>10.0.5.127</ns1:Name>
<ns1:NoChange>false</ns1:NoChange>
<ns1:CmDevices>
<ns1:item>
<ns1:Name>SEP04DAD2BF58D4</ns1:Name>
<ns1:DirNumber>5173-Registered</ns1:DirNumber>
<ns1:DeviceClass>Phone</ns1:DeviceClass>
<ns1:Model>435</ns1:Model>
<ns1:Product>334</ns1:Product>
<ns1:BoxProduct>0</ns1:BoxProduct>
<ns1:Httpd>Yes</ns1:Httpd>
<ns1:RegistrationAttempts>0</ns1:RegistrationAttempts>
<ns1:IsCtiControllable>true</ns1:IsCtiControllable>
<ns1:LoginUserId xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:Status>Registered</ns1:Status>
<ns1:StatusReason>0</ns1:StatusReason>
<ns1:PerfMonObject>2</ns1:PerfMonObject>
<ns1:DChannel>0</ns1:DChannel>
<ns1:Description>114_BEL_CR-PH</ns1:Description>
<ns1:H323Trunk>
<ns1:ConfigName xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:TechPrefix xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:Zone xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:RemoteCmServer1 xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:RemoteCmServer2 xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:RemoteCmServer3 xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:AltGkList xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:ActiveGk xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:CallSignalAddr xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:RasAddr xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</ns1:H323Trunk>
<ns1:TimeStamp>1494105234</ns1:TimeStamp>
<ns1:Protocol>SCCP</ns1:Protocol>
<ns1:NumOfLines>1</ns1:NumOfLines>
<ns1:LinesStatus>
<ns1:item>
<ns1:DirectoryNumber>5173</ns1:DirectoryNumber>
<ns1:Status>Registered</ns1:Status>
</ns1:item>
</ns1:LinesStatus>
<ns1:ActiveLoadID>SCCP45.9-4-2SR2-2S</ns1:ActiveLoadID>
<ns1:InactiveLoadID xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:DownloadStatus>Unknown</ns1:DownloadStatus>
<ns1:DownloadFailureReason xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:DownloadServer xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:IPAddress>
<ns1:item>
<ns1:IP>10.114.2.14</ns1:IP>
<ns1:IPAddrType>ipv4</ns1:IPAddrType>
<ns1:Attribute>AdministrativeAndSignaling</ns1:Attribute>
</ns1:item>
</ns1:IPAddress>
</ns1:item>
<ns1:item>
<ns1:Name>SEP04DAD2BF6F3D</ns1:Name>
<ns1:DirNumber>8001-Registered</ns1:DirNumber>
<ns1:DeviceClass>Phone</ns1:DeviceClass>
<ns1:Model>435</ns1:Model>
<ns1:Product>334</ns1:Product>
<ns1:BoxProduct>0</ns1:BoxProduct>
<ns1:Httpd>Yes</ns1:Httpd>
<ns1:RegistrationAttempts>0</ns1:RegistrationAttempts>
<ns1:IsCtiControllable>true</ns1:IsCtiControllable>
<ns1:LoginUserId xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:Status>Registered</ns1:Status>
<ns1:StatusReason>0</ns1:StatusReason>
<ns1:PerfMonObject>2</ns1:PerfMonObject>
<ns1:DChannel>0</ns1:DChannel>
<ns1:Description>115_MCD_PHN</ns1:Description>
<ns1:H323Trunk>
<ns1:ConfigName xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:TechPrefix xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:Zone xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:RemoteCmServer1 xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:RemoteCmServer2 xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:RemoteCmServer3 xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:AltGkList xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:ActiveGk xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:CallSignalAddr xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:RasAddr xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</ns1:H323Trunk>
<ns1:TimeStamp>1494259757</ns1:TimeStamp>
<ns1:Protocol>SCCP</ns1:Protocol>
<ns1:NumOfLines>1</ns1:NumOfLines>
<ns1:LinesStatus>
<ns1:item>
<ns1:DirectoryNumber>8001</ns1:DirectoryNumber>
<ns1:Status>Registered</ns1:Status>
</ns1:item>
</ns1:LinesStatus>
<ns1:ActiveLoadID>SCCP45.9-4-2SR2-2S</ns1:ActiveLoadID>
<ns1:InactiveLoadID xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:DownloadStatus>Unknown</ns1:DownloadStatus>
<ns1:DownloadFailureReason xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:DownloadServer xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:IPAddress>
<ns1:item>
<ns1:IP>10.115.2.18</ns1:IP>
<ns1:IPAddrType>ipv4</ns1:IPAddrType>
<ns1:Attribute>AdministrativeAndSignaling</ns1:Attribute>
</ns1:item>
</ns1:IPAddress>
</ns1:item>
</ns1:CmDevices>
</ns1:item>
<ns1:item>
<ns1:ReturnCode>NotFound</ns1:ReturnCode>
<ns1:Name>10.0.5.128</ns1:Name>
<ns1:NoChange>true</ns1:NoChange>
<ns1:CmDevices xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</ns1:item>
</ns1:CmNodes>
</ns1:SelectCmDeviceResult>
<ns1:StateInfo><StateInfo><Node Name="10.0.5.125" SubsystemStartTime="1492659312" StateId="1478" TotalItemsFound="20" TotalItemsReturned="2"/><Node Name="10.0.5.127" SubsystemStartTime="1492661102" StateId="5649" TotalItemsFound="232" TotalItemsReturned="2"/><Node Name="10.0.5.128" SubsystemStartTime="0" StateId="0" TotalItemsFound="0" TotalItemsReturned="0"/></StateInfo></ns1:StateInfo>
</ns1:selectCmDeviceReturn>
</ns1:selectCmDeviceResponse>
</soapenv:Body>
</soapenv:Envelope>
何が問題なのですか? XmlNodeListが空であるか、GetNodeValueは何も返しませんか?後者の場合は、そのコードも必要です。 – rene
正直に分からない、私はそのリストを考える。私は今日このように長らくハッキングしているので、項目変数が空であったので、リストを仮定しているだけです。 – Bryant
Ok、私はもう少し推測して、シスコの名前空間の末尾のスラッシュを削除しました。私のリストには情報がありますが、項目の戻り値node.InnerTextにNullReferenceExceptionがあります。 – Bryant