Stack Overflow em Português Asked by Brunno Sena on January 27, 2021
Estou tentando consumir um webservice da TOTVs.
Meu código PHP:
// SOAP client
$wsdl = 'http://localhost/TOTVSBusinessConnect/wsDataServer.asmx?wsdl';
$endpoint = array
(
'location' => 'http://localhost/TOTVSBusinessConnect/wsDataServer.asmx'
);
$soapClient = new SoapClient($wsdl, $endpoint);
$result = $soapClient->ReadRecordAuth(array('DataServerName' => 'GlbUsuarioData', 'PrimaryKey' => '$us', 'Contexto' => 'COLIGADA=1', 'Usuario' => $us, 'Senha' => $ps));
De retorno to fazendo assim:
$xml = simplexml_load_string($result->ReadRecordAuthResult) or die("Error: Cannot create object");
var_dump($xml);
Mas recebo o seguinte resultado:
object(SimpleXMLElement)#1 (0) {
}
Testei no SoapUI e me dá o seguinte resultado:
<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" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <soap:Header>
<wsa:Action>http://www.totvs.com.br/br/ReadRecordAuthResponse</wsa:Action>
<wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
<wsse:Security>
<wsu:Timestamp wsu:Id="Timestamp-4c70a96c-e82b-4740-a617-17400c63dcd8">
<wsu:Created>2016-12-28T11:11:52Z</wsu:Created>
<wsu:Expires>2016-12-28T11:16:52Z</wsu:Expires>
</wsu:Timestamp>
</wsse:Security> </soap:Header> <soap:Body>
<ReadRecordAuthResponse xmlns="http://www.totvs.com.br/br/">
<ReadRecordAuthResult><![CDATA[<GlbUsuario> <xs:schema id="GlbUsuario" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="GlbUsuario" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msdata:EnforceConstraints="False">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="GUSUARIO">
<xs:complexType>
<xs:sequence>
<xs:element name="CODUSUARIO" msdata:Caption="Usuário" default="">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="20" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="NOME" msdata:Caption="Nome" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="45" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="STATUS" msdata:Caption="Ativo" type="xs:short" default="1" minOccurs="0" />
<xs:element name="DATAINICIO" msdata:Caption="Início de Validade" msdata:DateTimeMode="Unspecified" type="xs:dateTime" default="2016-12-28T00:00:00" minOccurs="0" />
<xs:element name="DATAEXPIRACAO" msdata:Caption="Expiração de Validade" msdata:DateTimeMode="Unspecified" type="xs:dateTime" minOccurs="0" />
<xs:element name="CONFIRMABTNOK" msdata:Caption="Confirmação de Operação" type="xs:short" default="1" minOccurs="0" />
<xs:element name="SENHA" msdata:Caption="Senha " type="xs:string" />
<xs:element name="CONTROLE" msdata:Caption="CRC do Usuário" type="xs:short" minOccurs="0" />
<xs:element name="ULTIMACOLIGADA" msdata:Caption="Última Coligada Acessada" type="xs:int" minOccurs="0" />
<xs:element name="CODACESSO" msdata:Caption="Código de Acesso">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="16" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="DTAEXPSENHA" msdata:Caption="Data de expiração da senha" msdata:DateTimeMode="Unspecified" type="xs:dateTime" minOccurs="0" />
<xs:element name="DIASEXPSENHA" msdata:Caption="Dias de expiração da senha" type="xs:int" minOccurs="0" />
<xs:element name="OBRIGAALTERARSENHA" msdata:Caption="Alterar senha no Próximo Login" default="T" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="1" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="NUMLOGININVALIDO" msdata:Caption="Número de Logins Inválidos" type="xs:int" minOccurs="0" />
<xs:element name="DATALOGININVALIDO" msdata:Caption="Data do último login inválido" msdata:DateTimeMode="Unspecified" type="xs:dateTime" minOccurs="0" />
<xs:element name="EMAIL" msdata:Caption="E-Mail" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="60" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="ACESSONET" msdata:Caption="Permite Acesso ao TOTVS RM Portal" default="F" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="1" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="DATAULTIMOACESSO" msdata:Caption="Data de último acesso" msdata:DateTimeMode="Unspecified" type="xs:dateTime" minOccurs="0" />
<xs:element name="CODUSUARIOREDE" msdata:Caption="Usuário de rede" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="20" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="DOMINIOREDE" msdata:Caption="Domínio de rede" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="256" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="LIVEID" msdata:ReadOnly="true" msdata:Caption="Usuário do Microsoft Live" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="150" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="USUARIOTWITTER" msdata:Caption="Usuário do Twitter" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="SENHATWITTER" msdata:Caption="Senha do Twitter" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="100" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="USUARIOFACEBOOK" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="SENHAFACEBOOK" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="100" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="USUARIOLINKEDIN" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="SENHALINKEDIN" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="100" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="FULLDETERMINED" type="xs:string" minOccurs="0" />
<xs:element name="USERID" msdata:Caption="UserId" default="" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="INTERNO1" type="xs:string" minOccurs="0" />
<xs:element name="DATAULTIMOACESSOVALIDO" msdata:DateTimeMode="Unspecified" type="xs:dateTime" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GPERMIS">
<xs:complexType>
<xs:sequence>
<xs:element name="CODCOLIGADA" type="xs:short" />
<xs:element name="CODSISTEMA" default="G">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="1" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="CODUSUARIO" default="brunno.nascimento">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="20" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="SUPERVISOR" type="xs:short" minOccurs="0" />
<xs:element name="CONTROLE" type="xs:short" minOccurs="0" />
<xs:element name="CRIARELAT" type="xs:short" minOccurs="0" />
<xs:element name="RECCREATEDBY" type="xs:string" minOccurs="0" />
<xs:element name="RECCREATEDON" msdata:DateTimeMode="Unspecified" type="xs:dateTime" minOccurs="0" />
<xs:element name="RECMODIFIEDBY" type="xs:string" minOccurs="0" />
<xs:element name="RECMODIFIEDON" msdata:DateTimeMode="Unspecified" type="xs:dateTime" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GUSRPERFIL">
<xs:complexType>
<xs:sequence>
<xs:element name="CODCOLIGADA" type="xs:short" />
<xs:element name="CODUSUARIO" default="brunno.nascimento">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="20" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="CODSISTEMA" default="G">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="1" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="CODPERFIL">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="15" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="INDICE" type="xs:short" />
<xs:element name="CONTROLE" type="xs:short" minOccurs="0" />
<xs:element name="RECCREATEDBY" type="xs:string" minOccurs="0" />
<xs:element name="RECCREATEDON" msdata:DateTimeMode="Unspecified" type="xs:dateTime" minOccurs="0" />
<xs:element name="RECMODIFIEDBY" type="xs:string" minOccurs="0" />
<xs:element name="RECMODIFIEDON" msdata:DateTimeMode="Unspecified" type="xs:dateTime" minOccurs="0" />
<xs:element name="STATUS" type="xs:short" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1" msdata:PrimaryKey="true">
<xs:selector xpath=".//GUSUARIO" />
<xs:field xpath="CODUSUARIO" />
</xs:unique>
<xs:unique name="GPERMIS_Constraint1" msdata:ConstraintName="Constraint1" msdata:PrimaryKey="true">
<xs:selector xpath=".//GPERMIS" />
<xs:field xpath="CODCOLIGADA" />
<xs:field xpath="CODSISTEMA" />
<xs:field xpath="CODUSUARIO" />
</xs:unique>
<xs:unique name="GUSRPERFIL_Constraint1" msdata:ConstraintName="Constraint1" msdata:PrimaryKey="true">
<xs:selector xpath=".//GUSRPERFIL" />
<xs:field xpath="CODCOLIGADA" />
<xs:field xpath="CODUSUARIO" />
<xs:field xpath="CODSISTEMA" />
<xs:field xpath="CODPERFIL" />
</xs:unique>
<xs:keyref name="FK_GUSUARIO_GPERMIS" refer="Constraint1">
<xs:selector xpath=".//GPERMIS" />
<xs:field xpath="CODUSUARIO" />
</xs:keyref>
</xs:element>
<xs:annotation>
<xs:appinfo>
<msdata:Relationship name="FKGUSRPERFIL_GPERMIS" msdata:parent="GPERMIS" msdata:child="GUSRPERFIL" msdata:parentkey="CODCOLIGADA CODSISTEMA CODUSUARIO" msdata:childkey="CODCOLIGADA CODSISTEMA CODUSUARIO" />
</xs:appinfo>
</xs:annotation> </xs:schema> <GUSUARIO>
<CODUSUARIO>usuario</CODUSUARIO>
<NOME>nomeusuario</NOME>
<STATUS>1</STATUS>
<DATAINICIO>2015-10-01T00:00:00</DATAINICIO>
<CONFIRMABTNOK>1</CONFIRMABTNOK>
<CONTROLE>31921</CONTROLE>
<ULTIMACOLIGADA>1</ULTIMACOLIGADA>
<CODACESSO>Default</CODACESSO>
<DTAEXPSENHA>2015-12-08T00:00:00</DTAEXPSENHA>
<OBRIGAALTERARSENHA>F</OBRIGAALTERARSENHA>
<NUMLOGININVALIDO>0</NUMLOGININVALIDO>
<EMAIL>emailusuario</EMAIL>
<ACESSONET>F</ACESSONET>
<DATAULTIMOACESSO>2016-12-28T09:11:52.28</DATAULTIMOACESSO>
<SENHATWITTER>FEz1B7F118B727</SENHATWITTER>
<SENHAFACEBOOK>FEz1B7F118B727</SENHAFACEBOOK>
<SENHALINKEDIN>FEz1B7F118B727</SENHALINKEDIN>
<FULLDETERMINED />
<USERID>01a8d451-7105-4d79-8761-e2c39ecc7ca4</USERID>
<DATAULTIMOACESSOVALIDO>2016-12-28T09:11:52.28</DATAULTIMOACESSOVALIDO> </GUSUARIO> </GlbUsuario>]]></ReadRecordAuthResult>
</ReadRecordAuthResponse> </soap:Body> </soap:Envelope>
Na aba “Raw” me apresenta:
HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Content-Length: 16422
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Set-Cookie: ASP.NET_SessionId=tfy4ersu0eyplf12osjb133n; path=/; HttpOnly
X-Powered-By: ASP.NET
Date: Wed, 28 Dec 2016 11:11:52 GMT
<?xml version="1.0" encoding="utf-8"?><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" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><soap:Header><wsa:Action>http://www.totvs.com.br/br/ReadRecordAuthResponse</wsa:Action><wsa:MessageID>urn:uuid:f6e378f5-24b2-42eb-9b10-87d6269bc7ab</wsa:MessageID><wsa:RelatesTo>urn:uuid:480adf3b-5fd0-4319-952f-b88d8718ffd5</wsa:RelatesTo><wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To><wsse:Security><wsu:Timestamp wsu:Id="Timestamp-4c70a96c-e82b-4740-a617-17400c63dcd8"><wsu:Created>2016-12-28T11:11:52Z</wsu:Created><wsu:Expires>2016-12-28T11:16:52Z</wsu:Expires></wsu:Timestamp></wsse:Security></soap:Header><soap:Body><ReadRecordAuthResponse xmlns="http://www.totvs.com.br/br/"><ReadRecordAuthResult><GlbUsuario>
<xs:schema id="GlbUsuario" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="GlbUsuario" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msdata:EnforceConstraints="False">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="GUSUARIO">
<xs:complexType>
<xs:sequence>
<xs:element name="CODUSUARIO" msdata:Caption="Usuário" default="">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="20" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="NOME" msdata:Caption="Nome" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="45" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="STATUS" msdata:Caption="Ativo" type="xs:short" default="1" minOccurs="0" />
<xs:element name="DATAINICIO" msdata:Caption="InÃcio de Validade" msdata:DateTimeMode="Unspecified" type="xs:dateTime" default="2016-12-28T00:00:00" minOccurs="0" />
<xs:element name="DATAEXPIRACAO" msdata:Caption="Expiração de Validade" msdata:DateTimeMode="Unspecified" type="xs:dateTime" minOccurs="0" />
<xs:element name="CONFIRMABTNOK" msdata:Caption="Confirmação de Operação" type="xs:short" default="1" minOccurs="0" />
<xs:element name="SENHA" msdata:Caption="Senha " type="xs:string" />
<xs:element name="CONTROLE" msdata:Caption="CRC do Usuário" type="xs:short" minOccurs="0" />
<xs:element name="ULTIMACOLIGADA" msdata:Caption="Última Coligada Acessada" type="xs:int" minOccurs="0" />
<xs:element name="CODACESSO" msdata:Caption="Código de Acesso">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="16" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="DTAEXPSENHA" msdata:Caption="Data de expiração da senha" msdata:DateTimeMode="Unspecified" type="xs:dateTime" minOccurs="0" />
<xs:element name="DIASEXPSENHA" msdata:Caption="Dias de expiração da senha" type="xs:int" minOccurs="0" />
<xs:element name="OBRIGAALTERARSENHA" msdata:Caption="Alterar senha no Próximo Login" default="T" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="1" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="NUMLOGININVALIDO" msdata:Caption="Número de Logins Inválidos" type="xs:int" minOccurs="0" />
<xs:element name="DATALOGININVALIDO" msdata:Caption="Data do último login inválido" msdata:DateTimeMode="Unspecified" type="xs:dateTime" minOccurs="0" />
<xs:element name="EMAIL" msdata:Caption="E-Mail" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="60" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="ACESSONET" msdata:Caption="Permite Acesso ao TOTVS RM Portal" default="F" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="1" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="DATAULTIMOACESSO" msdata:Caption="Data de último acesso" msdata:DateTimeMode="Unspecified" type="xs:dateTime" minOccurs="0" />
<xs:element name="CODUSUARIOREDE" msdata:Caption="Usuário de rede" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="20" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="DOMINIOREDE" msdata:Caption="DomÃnio de rede" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="256" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="LIVEID" msdata:ReadOnly="true" msdata:Caption="Usuário do Microsoft Live" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="150" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="USUARIOTWITTER" msdata:Caption="Usuário do Twitter" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="SENHATWITTER" msdata:Caption="Senha do Twitter" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="100" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="USUARIOFACEBOOK" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="SENHAFACEBOOK" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="100" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="USUARIOLINKEDIN" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="SENHALINKEDIN" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="100" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="FULLDETERMINED" type="xs:string" minOccurs="0" />
<xs:element name="USERID" msdata:Caption="UserId" default="" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="INTERNO1" type="xs:string" minOccurs="0" />
<xs:element name="DATAULTIMOACESSOVALIDO" msdata:DateTimeMode="Uns
Se puderem me ajudar, agradeço !
Tente desse jeito
try{
$client = new SoapClient($wsdl, array('trace' => $trace, 'exceptions' => $exceptions));
$response = $client->ReadRecordAuth(array('DataServerName' => 'GlbUsuarioData', 'PrimaryKey' => '$us', 'Contexto' => 'COLIGADA=1', 'Usuario' => $us, 'Senha' => $ps));
}
catch (Exception $e)
{
echo "Error!";
echo $e -> getMessage ();
echo 'Last response: '. $client->__getLastResponse();
}
echo "<pre>";
print_r($response);
echo "</pre>";
Answered by Lucas Torres on January 27, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP