I am using monitoring plugin 1.6.0 with openfire 4.2.0.
Following is the screenshot of archive settings on openfire admin Console.
also following is the screenshot of plugins I am using with this.
My Issue
as you can see the plugin is installed.
but when I am trying to fetch chat history with following code : I am getting service unavailable response.
func fetchChatHistoryFromServer(completionHandler completion: #escaping FetchChatHistoryCompletionHandler) {
let iq = DDXMLElement(name: "iq")
iq.addAttribute(withName: "type", stringValue: "set")
iq.addAttribute(withName: "id", stringValue: UserManager.shared.activeUser.jid)
let query = DDXMLElement(name: "query")
query.setXmlns("urn:xmpp:mam:2")
query.addAttribute(withName: "queryid", stringValue: XMPPManager.shared.xmppStream.generateUUID)
let x = DDXMLElement(name: "x")
x.setXmlns("jabber:x:data")
x.addAttribute(withName: "type", stringValue: "submit")
let field = DDXMLElement(name: "field")
field.addAttribute(withName: "var", stringValue: "FORM_TYPE")
field.addAttribute(withName: "type", stringValue: "hidden")
let fieldValue = DDXMLElement(name: "value", stringValue: "urn:xmpp:mam:2")
field.addChild(fieldValue)
x.addChild(field)
query.addChild(x)
iq.addChild(query)
//let xmppResultSet = XMPPResultSet(max: 2000)
Logger.log(iq)
didFetchChatHistoryCompletionBlock = completion
xmppMessageArchivingManagement?.retrieveMessageArchive(withFields: [iq], with: nil)
}
OutPut Log :-
<iq type="set" id="dev60#dev.myapp.com">
<query xmlns="urn:xmpp:mam:2" queryid="20B07616-12BC-41BB-9DE6-F0F6A74951A5">
<x xmlns="jabber:x:data" type="submit">
<field var="FORM_TYPE" type="hidden">
<value>urn:xmpp:mam:2</value>
</field>
</x>
</query>
</iq>
Response :--
<iq xmlns="jabber:client" type="error" id="7BED0303-46E3-40D4-BE47-543BB7810F66" to="dev60#dev.myapp.com/a3lb3jaw9g">
<query xmlns="urn:xmpp:mam:2" queryid="80D6D753-B2BF-4626-84B5-C216D4B94996">
<x xmlns="jabber:x:data" type="submit">
<field var="FORM_TYPE" type="hidden">
<value>urn:xmpp:mam:2</value>
</field>
<iq type="set" id="dev60#dev.myapp.com">
<query xmlns="urn:xmpp:mam:2" queryid="20B07616-12BC-41BB-9DE6-F0F6A74951A5">
<x xmlns="jabber:x:data" type="submit">
<field var="FORM_TYPE" type="hidden">
<value>urn:xmpp:mam:2</value>
</field>
</x>
</query>
</iq>
</x>
</query>
<error code="503" type="cancel">
<service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"></service-unavailable>
</error>
openfire do not support urn:xmpp:mam:2 you have to use urn:xmpp:mam:1 instead.
you have to change it in XMPPMessageArchiveManagemnt class.
just go to XMPPMessageArchiveManagement class .in line of 20 it said
/** 'urn:xmpp:mam:2' */ extern NSString *const XMLNS_XMPP_MAM;.
just hold command and click on XMLNS_XMPP_MAM after that change urn:xmpp:mam:2 to urn:xmpp:mam:1
Related
Given this XML:
<DTS:Executable xmlns:DTS="www.microsoft.com/SqlServer/Dts" DTS:refId="Package" DTS:CreationDate="11/29/2011 1:47:31 AM" DTS:CreationName="Microsoft.Package" DTS:CreatorComputerName="MyComp" DTS:CreatorName="dbo\administrator" DTS:Description="SSIS Package Description" DTS:DTSID="{3BBFC5EF-56B7-44D3-A078-7967F8C6149B}" DTS:EnableConfig="True" DTS:ExecutableType="Microsoft.Package" DTS:LastModifiedProductVersion="12.0.2000.8" DTS:LocaleID="1033" DTS:MaxErrorCount="0" DTS:ObjectName="pkgName" DTS:VersionBuild="69" DTS:VersionGUID="{86355AA2-4B44-46F3-8F21-2B4EF047044D}">
<DTS:Property DTS:Name="PackageFormatVersion">8</DTS:Property>
<DTS:ConnectionManagers>
<DTS:ConnectionManager DTS:refId="Package.ConnectionManagers[filename.txt]" DTS:CreationName="FLATFILE" DTS:DTSID="{C2C47A96-2F93-4B27-8F75-EEAB49BFB993}" DTS:ObjectName="filename.txt">
<DTS:ObjectData>
<DTS:ConnectionManager DTS:Format="RaggedRight" DTS:LocaleID="1033" DTS:HeaderRowDelimiter="_x000D__x000A_" DTS:RowDelimiter="" DTS:TextQualifier="_x003C_none_x003E_" DTS:CodePage="1252" DTS:ConnectionString="D:\batch\dataFiles\filename.txt">
<DTS:FlatFileColumns>
<DTS:FlatFileColumn DTS:ColumnDelimiter="" DTS:ColumnWidth="9" DTS:MaximumWidth="9" DTS:DataType="129" DTS:TextQualified="True" DTS:ObjectName="ssn" DTS:DTSID="{D5EE68E0-149C-4EF9-A521-09D0E5F2542F}" DTS:CreationName="" />
<DTS:FlatFileColumn DTS:ColumnDelimiter="" DTS:ColumnWidth="3" DTS:MaximumWidth="3" DTS:DataType="129" DTS:TextQualified="True" DTS:ObjectName="component" DTS:DTSID="{DBCF7A29-A2E3-42B6-A04F-956DBAC79F8B}" DTS:CreationName="" />
<DTS:FlatFileColumn DTS:ColumnDelimiter="" DTS:ColumnWidth="8" DTS:MaximumWidth="8" DTS:DataType="129" DTS:TextQualified="True" DTS:ObjectName="component_date" DTS:DTSID="{58D32551-9D64-4A58-96F7-B7892450581E}" DTS:CreationName="" />
<DTS:FlatFileColumn DTS:ColumnDelimiter="" DTS:ColumnWidth="20" DTS:MaximumWidth="20" DTS:DataType="129" DTS:TextQualified="True" DTS:ObjectName="emp_name" DTS:DTSID="{BA178333-E8AB-49EF-838E-33D344857EDB}" DTS:CreationName="" />
<DTS:FlatFileColumn DTS:ColumnDelimiter="" DTS:ColumnWidth="25" DTS:MaximumWidth="25" DTS:DataType="129" DTS:TextQualified="True" DTS:ObjectName="emp_street" DTS:DTSID="{3A08B6F4-5A04-4280-A1A7-A3F21730BC8C}" DTS:CreationName="" />
<DTS:FlatFileColumn DTS:ColumnDelimiter="" DTS:ColumnWidth="18" DTS:MaximumWidth="18" DTS:DataType="129" DTS:TextQualified="True" DTS:ObjectName="emp_city" DTS:DTSID="{CD9D7AAF-C664-4AB8-AD2A-ECE88F1C0900}" DTS:CreationName="" />
<DTS:FlatFileColumn DTS:ColumnDelimiter="" DTS:ColumnWidth="2" DTS:MaximumWidth="2" DTS:DataType="129" DTS:TextQualified="True" DTS:ObjectName="emp_state" DTS:DTSID="{60DE0571-2E94-4FD7-8A97-EEB7AE1F4515}" DTS:CreationName="" />
<DTS:FlatFileColumn DTS:ColumnDelimiter="" DTS:ColumnWidth="9" DTS:MaximumWidth="9" DTS:DataType="129" DTS:TextQualified="True" DTS:ObjectName="emp_zip" DTS:DTSID="{2727BECF-749F-46B9-BF1D-9B0081BECA62}" DTS:CreationName="" />
<DTS:FlatFileColumn DTS:ColumnDelimiter="" DTS:ColumnWidth="7" DTS:MaximumWidth="7" DTS:DataType="129" DTS:TextQualified="True" DTS:ObjectName="emp_phone" DTS:DTSID="{D5B7BB28-913C-4B38-B849-23431C2BE932}" DTS:CreationName="" />
<DTS:FlatFileColumn DTS:ColumnDelimiter="" DTS:ColumnWidth="25" DTS:MaximumWidth="25" DTS:DataType="129" DTS:TextQualified="True" DTS:ObjectName="work_type" DTS:DTSID="{9E321BD3-A960-47A0-9A29-972053449516}" DTS:CreationName="" />
<DTS:FlatFileColumn DTS:ColumnDelimiter="" DTS:ColumnWidth="2" DTS:MaximumWidth="2" DTS:DataType="129" DTS:TextQualified="True" DTS:ObjectName="hours_per_week" DTS:DTSID="{BA0C9BC9-C295-4460-A2A6-2DF0D7D254A6}" DTS:CreationName="" />
<DTS:FlatFileColumn DTS:ColumnDelimiter="" DTS:ColumnWidth="7" DTS:MaximumWidth="7" DTS:DataType="129" DTS:TextQualified="True" DTS:ObjectName="wages" DTS:DTSID="{34EC742F-5133-4DEC-A568-3092A23DCA79}" DTS:CreationName="" />
<DTS:FlatFileColumn DTS:ColumnDelimiter="" DTS:ColumnWidth="8" DTS:MaximumWidth="8" DTS:DataType="129" DTS:TextQualified="True" DTS:ObjectName="start_date" DTS:DTSID="{AC63CADC-2E7A-43C9-91C4-F02F24AA19A0}" DTS:CreationName="" />
<DTS:FlatFileColumn DTS:ColumnDelimiter="" DTS:ColumnWidth="1" DTS:MaximumWidth="1" DTS:DataType="129" DTS:TextQualified="True" DTS:ObjectName="parm_employment" DTS:DTSID="{5DDFBA20-D527-4FFA-88D1-2E996D7997A2}" DTS:CreationName="" />
<DTS:FlatFileColumn DTS:ColumnDelimiter="" DTS:ColumnWidth="1" DTS:MaximumWidth="1" DTS:DataType="129" DTS:TextQualified="True" DTS:ObjectName="P_T_employment" DTS:DTSID="{A35AB03E-9323-4CA7-B7D7-3E4C7DD7A2B2}" DTS:CreationName="" />
<DTS:FlatFileColumn DTS:ColumnDelimiter="" DTS:ColumnWidth="20" DTS:MaximumWidth="20" DTS:DataType="129" DTS:TextQualified="True" DTS:ObjectName="employee_name" DTS:DTSID="{5C5079CB-48F8-415A-9DB3-8BE8CFF156BB}" DTS:CreationName="" />
<DTS:FlatFileColumn DTS:ColumnType="Delimited" DTS:ColumnDelimiter="_x000D__x000A_" DTS:MaximumWidth="4" DTS:DataType="129" DTS:TextQualified="True" DTS:ObjectName="local_office" DTS:DTSID="{3BED2123-DF68-43C9-B777-5A7282F36057}" DTS:CreationName="" />
</DTS:FlatFileColumns>
</DTS:ConnectionManager>
</DTS:ObjectData>
</DTS:ConnectionManager>
<DTS:ConnectionManager DTS:refId="Package.ConnectionManagers[Configuration Connection]" DTS:CreationName="OLEDB" DTS:DTSID="{05edc4ae-ddea-49c9-a430-4d9a3119ec7c}" DTS:ObjectName="Configuration Connection">
<DTS:ObjectData>
<DTS:ConnectionManager DTS:ConnectionString="Data Source=(local);Initial Catalog=SSISConfigs;Provider=SQLNCLI11;Integrated Security=SSPI;Auto Translate=False;Application Name=SSIS-Package-{E0462A98-CA65-44B0-A74B-90AE4E5B1EEE}deswcrmssqlq1.server.SSISConfigs;" />
</DTS:ObjectData>
</DTS:ConnectionManager>
<DTS:ConnectionManager DTS:refId="Package.ConnectionManagers[Production]" DTS:CreationName="OLEDB" DTS:DTSID="{E06BCA4D-7F8B-41E0-848E-7DCD47731D44}" DTS:ObjectName="Production">
<DTS:ObjectData>
<DTS:ConnectionManager DTS:ConnectionString="Data Source=(local);Initial Catalog=production;Provider=SQLNCLI11;Integrated Security=SSPI;Auto Translate=false;Application Name=SSIS-Package-{E06BCA4D-7F8B-41E0-848E-7DCD47731D44}(local) production;" />
</DTS:ObjectData>
</DTS:ConnectionManager>
<DTS:ConnectionManager DTS:refId="Package.ConnectionManagers[SMTP Connection Manager]" DTS:CreationName="SMTP" DTS:DTSID="{1445d2e3-744c-46ed-809f-ab9f5c30eb0e}" DTS:ObjectName="SMTP Connection Manager">
<DTS:ObjectData>
<SmtpConnectionManager ConnectionString="SmtpServer=mail.myserver.com;UseWindowsAuthentication=True;EnableSsl=False;" />
</DTS:ObjectData>
</DTS:ConnectionManager>
</DTS:ConnectionManagers>
<DTS:Configurations>
<DTS:Configuration DTS:ConfigurationString=""Configuration Connection";"[dbo].[SSIS Configurations]";"package";" DTS:ConfigurationType="7" DTS:CreationName="" DTS:DTSID="{FEA2D0C6-ED02-451D-9038-8E63A555E1D1}" DTS:ObjectName="Configuration 2" />
</DTS:Configurations>
<DTS:Variables>
<DTS:Variable DTS:CreationName="" DTS:DTSID="{4B742A03-0599-471D-B8D1-E444DD74FCF8}" DTS:IncludeInDebugDump="2345" DTS:Namespace="User" DTS:ObjectName="FTPFile">
<DTS:VariableValue DTS:DataType="8">\\myserver\c$\cygwin64\path\filename.txt</DTS:VariableValue>
</DTS:Variable>
</DTS:Variables>
<DTS:Executables>
<DTS:Executable DTS:refId="Package\Delete Existing File from FTP Server" DTS:CreationName="Microsoft.FileSystemTask" DTS:Description="File System Task" DTS:DTSID="{EB57CB73-8CAD-4157-87F6-66E84EE9AA4C}" DTS:ExecutableType="Microsoft.FileSystemTask" DTS:LocaleID="-1" DTS:ObjectName="Delete Existing File from FTP Server" DTS:TaskContact="File System Task;Microsoft Corporation; Microsoft SQL Server 2008 R2; © 2007 Microsoft Corporation; All Rights Reserved;http://www.microsoft.com/sql/support/default.asp;1" DTS:ThreadHint="0">
<DTS:Variables />
<DTS:ObjectData>
<FileSystemData TaskOperationType="DeleteFile" TaskSourcePath="User::FTPFile" TaskIsSourceVariable="True" />
</DTS:ObjectData>
</DTS:Executable>
<DTS:Executable DTS:refId="Package\Extract data to file" DTS:CreationName="Microsoft.Pipeline" DTS:DelayValidation="True" DTS:DTSID="{3E3B3666-30B4-4EAE-B962-72775E7A5A36}" DTS:ExecutableType="Microsoft.Pipeline" DTS:FailPackageOnFailure="True" DTS:LocaleID="-1" DTS:ObjectName="Extract data to file" DTS:TaskContact="Performs high-performance data extraction, transformation and loading;Microsoft Corporation; Microsoft SQL Server v10; (C) 2007 Microsoft Corporation; All Rights Reserved;http://www.microsoft.com/sql/support/default.asp;1">
<DTS:Variables />
<DTS:ObjectData>
<pipeline BLOBTempStoragePath="" bufferTempStoragePath="" defaultBufferSize="3145728" version="1">
<components>
<component refId="Package\Extract data to file\Destination - file_export_txt" componentClassID="Microsoft.FlatFileDestination" contactInfo="Flat File Destination;Microsoft Corporation; Microsoft SqlServer v10; (C) Microsoft Corporation; All Rights Reserved; http://www.microsoft.com/sql/support;0" description="Flat File Destination" localeId="1033" name="Destination - file_export_txt" validateExternalMetadata="False">
<properties>
<property dataType="System.Boolean" description="Specifies whether the data will overwrite or append to the destination file." name="Overwrite">true</property>
<property dataType="System.Null" description="Specifies the text to write to the destination file before any data is written." expressionType="Notify" name="Header" />
</properties>
<connections>
<connection refId="Package\Extract data to file\Destination - file_export_txt.Connections[FlatFileConnection]" connectionManagerID="Package.ConnectionManagers[filename.txt]" connectionManagerRefId="Package.ConnectionManagers[filename.txt]" name="FlatFileConnection" />
</connections>
...
What do I need to use as far as nodes to get the value for connectionManagerRefId (second line from the bottom)?
I'm trying:
WITH XMLNAMESPACES ('www.microsoft.com/SqlServer/Dts' AS DTS) -- declare XML namespaces
SELECT t.e.value('#DTS:DTSID','varchar(100)') AS DTSID,
t.e.value('#DTS:ObjectName','varchar(100)') AS ObjectName,
ex.st.value('#DTS:refId','varchar(max)') AS StepID,
ex.st.value('#DTS:ObjectName','varchar(max)') AS StepName,
ex.st.value('#DTS:Description','varchar(max)') AS StepDesc,
cx.cn.value('(connectionManagerRefId)[1]','varchar(max)') AS StepConn
FROM #SSISPackagesList PackageXML
CROSS APPLY PackageXMLContent.nodes('DTS:Executable') t(e)
OUTER APPLY t.e.nodes('DTS:Executables/DTS:Executable') AS ex(st) --Control flow steps
OUTER APPLY ex.st.nodes('DTS:ObjectData/pipeline/components/component/connections/connection') cx(cn);
Where #SSISPackagesList.PackageXMLContent contains the XML to be searched. This query successfully returns values for every column EXCEPT StepConn. I'm fairly new to XML and extracting data from it, so I'm guessing this has something to do with missing [1] values, but I'm not not quite sure how. Thank you for your assistance solving this; any explanation you can provide for my future knowledge would also be greatly appreciated.
Looks like it was just a small syntax error that needed fixing (see below):
SELECT t.e.value('#DTS:DTSID','varchar(100)') AS DTSID,
t.e.value('#DTS:ObjectName','varchar(100)') AS ObjectName,
ex.st.value('#DTS:refId','varchar(max)') AS StepID,
ex.st.value('#DTS:ObjectName','varchar(max)') AS StepName,
ex.st.value('#DTS:Description','varchar(max)') AS StepDesc,
cx.cn.value('#connectionManagerRefId[1]','varchar(max)') AS StepConn
FROM #SSISPackagesList PackageXML
CROSS APPLY PackageXMLContent.nodes('DTS:Executable') t(e)
OUTER APPLY t.e.nodes('DTS:Executables/DTS:Executable') AS ex(st) --Control flow steps
OUTER APPLY ex.st.nodes('DTS:ObjectData/pipeline/components/component/connections/connection') cx(cn)
Property name needed an '#' in front of it.
I fetched History from openfire by installing open fire plugin in the open fire and tried this code.
let iq1 = DDXMLElement(name: "iq")
iq1.addAttribute(withName: "type", stringValue: "get")
iq1.addAttribute(withName: "id", stringValue: "0")
let retrieve = DDXMLElement(name: "retrieve", xmlns: "urn:xmpp:archive")
retrieve?.addAttribute(withName: "with", stringValue: "raman#ip-172-31-53-77.ec2.internal")
let set = DDXMLElement(name: "set", xmlns: "http://jabber.org/protocol/rsm")
let max = DDXMLElement(name: "max", stringValue: "50")
iq1.addChild(retrieve!)
retrieve?.addChild(set!)
set?.addChild(max)
stream?.send(iq1 )
Now i am not getting history from Both Side. here is the result that i get.
<iq xmlns="jabber:client"
type="result"
id="0"
to="bentick#ip-172-31-53-77.ec2.internal/5qsinh1syg">
<chat xmlns="urn:xmpp:archive"
with="raman#ip-172-31-53-77.ec2.internal"
start="2017-02-07T06:28:33.691Z">
<from secs="0">
<body>hello</body>
</from>
<from secs="405">
<body>hiii</body>
</from>
<from secs="580">
<body>Hey</body>
</from>
<from secs="599">
<body>HooooE</body>
</from>
<from secs="628">
<body>hOo</body>
</from>
<from secs="907">
<body>Raman here</body>
</from>
<from secs="931">
<body>Raman here ONE</body>
</from>
<from secs="1273">
<body>Raman here</body>
</from>
<from secs="1558">
<body> Raman from SPark </body>
</from>
<from secs="1571">
<body> Raman from SPark One</body>
</from>
<from secs="1782">
<body>Raman from SPark </body>
</from>
<from secs="2651">
<body>Raman FiVE</body>
</from>
<from secs="2810">
<body>Raman Three</body>
</from>
<from secs="2810">
<body>Raman FOur</body>
</from>
<from secs="3534">
<body>RAMAN SIX</body>
</from>
<from secs="4105">
<body>Raman OKK</body>
</from>
<from secs="4113">
<body>OKKK l</body>
</from>
<from secs="4130">
<body>UST</body>
</from>
<set xmlns="http://jabber.org/protocol/rsm">
<first index="0">0</first>
<last>17</last>
<count>18</count>
</set>
</chat>
</iq>
This is all the message of RAMAN not BENTICk as this two user involved in chatting while getting history i only get the message of RAMAN. not BENTICk
How to get history from both side user.
Please help.
I have implemented the same to get the Message to and from by sending the given iq
And I am getting the proper result.
let iQ = DDXMLElement.element(withName: "iq") as! DDXMLElement
iQ.addAttribute(withName: "type", stringValue: "get")
iQ.addAttribute(withName: "id", stringValue: (xmppHandler.xmppStream?.generateUUID())!)
let retrieve = DDXMLElement(name: "retrieve", xmlns: "urn:xmpp:archive")
retrieve?.addAttribute(withName: "with", stringValue: "\(JID!)#\(Utility.hostname)")
let set = DDXMLElement.element(withName: "set") as! DDXMLElement
set.addAttribute(withName: "xmlns", stringValue: "http://jabber.org/protocol/rsm")
let max = DDXMLElement.element(withName: "max") as! DDXMLElement
max.stringValue = "10"
max.addAttribute(withName:"xmlns", stringValue: "http://jabber.org/protocol/rsm")
iQ.addChild(retrieve!)
retrieve?.addChild(set)
set.addChild(max as DDXMLNode)
xmppHandler.xmppStream?.send(iQ)
<iq type="get" id="7705EEC5-3385-42D4-B748-B39C204ADB90"><retrieve xmlns="urn:xmpp:archive" with="0544008296#192.168.2.181"><set xmlns="http://jabber.org/protocol/rsm"><max xmlns="http://jabber.org/protocol/rsm">10</max></set></retrieve></iq>
Response
<iq xmlns="jabber:client" type="result" id="7705EEC5-3385-42D4-B748-B39C204ADB90" to="0509503847#192.168.2.181/Smack">
<chat xmlns="urn:xmpp:archive" with="0544008296#192.168.2.181" start="2017-02-28T09:55:27.068Z">
<from secs="0" jid="0544008296#192.168.2.181">
<body>Hiii rajeev</body>
</from>
<to secs="52">
<body>Hi
How r u</body>
</to>
<from secs="15" jid="0544008296#192.168.2.181"><body>I am good</body></from>
<to secs="8"><body>What abt u</body></to>
<to secs="169"><body>Hello testing chat</body></to>
<from secs="10" jid="0544008296#192.168.2.181"><body>Good</body></from>
<from secs="5" jid="0544008296#192.168.2.181"><body>Continue </body></from>
<to secs="834"><body>Ok
</body></to>
<to secs="8"><body>Nice chat
</body></to>
<from secs="232" jid="0544008296#192.168.2.181"><body>Heelo</body></from>
<set xmlns="http://jabber.org/protocol/rsm"><first index="0">0</first> <last>9</last><count>574</count></set></chat></iq>
I'm trying to implement a SOAP server using Zend Framework 2 in PHP5.5. I've come as far as this:
library.php
<?php
namespace Library;
class IncrementedInt
{
/**
* #var integer
**/
public $original;
/**
* #var integer
**/
public $incremented;
public function __construct($num)
{
$this->original = $num;
$this->incremented = ++$num;
}
}
webservice.php
<?php
require_once 'library.php';
require_once 'Zend/Loader/StandardAutoloader.php';
$loader = new Zend\Loader\StandardAutoloader(array('autoregister_zf' => true));
$loader->register();
class Math
{
/**
* This method takes ...
*
* #param integer $inputParam
* #return \Library\IncrementedInt
*/
public function increment($inputParam)
{
return new \Library\IncrementedInt($inputParam);
}
}
if (isset($_GET['wsdl'])) {
$autodiscover = new \Zend\Soap\AutoDiscover();
$autodiscover->setClass('Math')
->setBindingStyle(array('style' => 'document'))
->setUri('http://localhost' . $_SERVER['SCRIPT_NAME']);
header('Content-type: application/xml');
echo $autodiscover->toXml();
}
else {
// pointing to the current file here
$soap = new \Zend\Soap\Server('http://localhost' . $_SERVER['SCRIPT_NAME'] . '?wsdl');
$soap->setClass('Math');
$soap->handle();
}
Loading the URL http://localhost/webservice.php?wsdl in a browser will output:
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://localhost/webservice.php" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" name="Math" targetNamespace="http://localhost/webservice.php">
<script/>
<types>
<xsd:schema targetNamespace="http://localhost/webservice.php">
<xsd:element name="increment">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="inputParam" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="IncrementedInt">
<xsd:all>
<xsd:element name="original" type="xsd:int" nillable="true"/>
<xsd:element name="incremented" type="xsd:int" nillable="true"/>
</xsd:all>
</xsd:complexType>
<xsd:element name="incrementResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="incrementResult" type="tns:IncrementedInt"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
<portType name="MathPort">
<operation name="increment">
<documentation>This method takes ...</documentation>
<input message="tns:incrementIn"/>
<output message="tns:incrementOut"/>
</operation>
</portType>
<binding name="MathBinding" type="tns:MathPort">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="increment">
<soap:operation soapAction="http://localhost/webservice.php#increment"/>
<input>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="MathService">
<port name="MathPort" binding="tns:MathBinding">
<soap:address location="http://localhost/webservice.php"/>
</port>
</service>
<message name="incrementIn">
<part name="parameters" element="tns:increment"/>
</message>
<message name="incrementOut">
<part name="parameters" element="tns:incrementResponse"/>
</message>
</definitions>
As you can see the IncrementedInt class and its properties original and incremented are defined. Yet when I call the service with sending this XML (using soapUI):
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://localhost/webservice.php">
<soapenv:Header/>
<soapenv:Body>
<web:increment>
<inputParam xsi:type="xsd:int">2</inputParam>
</web:increment>
</soapenv:Body>
</soapenv:Envelope>
The server will respond like:
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://localhost/webservice.php" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:incrementResponse>
<return xsi:type="ns1:IncrementedInt"/>
</ns1:incrementResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
As you can see the return value is not expanded and it's just like the type is named. Has anyone successfully returned a complex type in ZF2 SOAP server? How? I searched the Internet for an example but I could not find any!
It turned out all I was missing was the fact that Zend Framework caches WSDLs by default. So all I needed to do was to:
<?php
require_once 'library.php';
require_once 'Zend/Loader/StandardAutoloader.php';
$loader = new Zend\Loader\StandardAutoloader(array('autoregister_zf' => true));
$loader->register();
class Math
{
/**
* This method takes ...
*
* #param integer $inputParam
* #return \Library\IncrementedInt
*/
public function increment($inputParam)
{
return new \Library\IncrementedInt($inputParam);
}
}
if (isset($_GET['wsdl'])) {
$autodiscover = new \Zend\Soap\AutoDiscover();
$autodiscover->setClass('Math')
->setUri('http://localhost' . $_SERVER['SCRIPT_NAME']);
header('Content-type: application/xml');
echo $autodiscover->toXml();
}
else {
// pointing to the current file here
$soap = new \Zend\Soap\Server('http://localhost' . $_SERVER['SCRIPT_NAME'] . '?wsdl', array('cache_wsdl' => WSDL_CACHE_NONE));
$soap->setClass('Math');
$soap->handle();
}
The changes are:
When instantiating a Server it is set as options to disable WSDL caching.
The ->setBindingStyle(array('style' => 'document')) method call to AutoDiscovery is omitted as it causes trouble and prevents a successful SOAP call.
I am trying to convert the DragnDrop listview from here https://github.com/commonsguy/cwac-touchlist to C# with Mono for Android.
Part of this custom View requires the use of some custom attributes that are declared as the following inside the file Resources/values/attrs.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="TouchListView">
<attr name="normal_height" format="dimension" />
<attr name="expanded_height" format="dimension" />
<attr name="grabber" format="reference" />
<attr name="dragndrop_background" format="color" />
<attr name="remove_mode">
<enum name="none" value="-1" />
<enum name="fling" value="0" />
<enum name="slide" value="1" />
<enum name="slideRight" value="1" />
<enum name="slideLeft" value="2" />
</attr>
</declare-styleable>
</resources>
I then try to use them inside my layout file like this:
<app.monodroid.TouchListView xmlns:tlv="http://schemas.android.com/apk/res/app.monodroid"
android:id="#+id/lstExercises"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/lExerciseActions"
android:drawSelectorOnTop="false"
tlv:normal_height="64dip"
tlv:grabber="#+id/icon"
tlv:remove_mode="slideRight"
/>
But when I try to build my project I get the following error message:
/Library/Frameworks/Mono.framework/External/xbuild/Novell/Novell.MonoDroid.Common.targets: Error: Tool exited with code: 1. Output: /Users/path_to_project/App.MonoDroid/obj/Debug/res/layout/add_session.axml:1: error: No resource identifier found for attribute 'normal_height' in package 'com.app.monodroid'
/Users/path_to_project/App.MonoDroid/obj/Debug/res/layout/add_session.axml:1: error: No resource identifier found for attribute 'grabber' in package 'com.app.monodroid'
/Users/path_to_project/App.MonoDroid/obj/Debug/res/layout/add_session.axml:1: error: No resource identifier found for attribute 'remove_mode' in package 'com.app.monodroid'
(App.MonoDroid)
The name of my project is App.MonoDroid.
How can I use these attributes inside my layout file?
These errors should go away if you declare a package name for your app. In the project properties, go to the Android Manifest tab, and you'll see a text field for Package Name:
... and then make sure you use this package name for your assembly and namespace:
and use it in your xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res/**app.monodroid**"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<**app.monodroid**.FICalendarView
android:id="#+id/FICalendar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
custom:dayStyle="1">
</**app.monodroid**.FICalendarView>
<Button
android:id="#+id/MyButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/Hello"/>
</LinearLayout>
where FICaldendarView is a custom view defined as:
namespace app.monodroid
{
public class FICalendarView : View
{
//private FICalenderView() {}
public FICalendarView(Context context)
: base(context)
{
}
public FICalendarView(Context context, Android.Util.IAttributeSet attribute)
: base(context, attribute)
{
Android.Content.Res.TypedArray a = context.Theme.ObtainStyledAttributes(attribute, Resource.Styleable.FICalendarView, 0, 0);
//Android.Util.TypedValue typedValue = null;
int dayStyle = a.GetInteger(Resource.Styleable.FICalendarView_dayStyle,0);
}
public FICalendarView(Context context, Android.Util.IAttributeSet attribute, int x)
: base(context, attribute,x)
{
}
}
}
How can i parse this xml file ?
<resultset>
−<row>
<field name="Table Name">table_1</field>
<field name="Quant of Rows">2</field>
<field name="Total Size Mb">0.02</field>
</row>
−<row>
<field name="Table Name">table_2</field>
<field name="Quant of Rows">1</field>
<field name="Total Size Mb">0.02</field>
</row>
</resultset>
I am using REXML.
table_data = []
xml = File.read('file1.xml')
doc, posts = REXML::Document.new(xml), []
doc.elements.each('resultset/row') do |table_row|
table_data << {:table_name => table_row.elements[1].text,
:record_count => table_row.elements[2].text,
:size_in_mb => table_row.elements[3].text
}
end