Boa tarde a todos. Eu estou tentando fazer um webservice com WSDL. Porém eu nunca fiz isso e não está funcionando. Alguém pode me ajudar ? Eu fiz estes arquivos:
<?php
include("loja.php");
include("sog.php");
$loja = new Loja();
$sog = new Sog();
$dados_loja = $loja->pegarDados();
$sog->setUsername("aaaa");
$sog->setPassword("bbbb123456");
$sog->setCustomerType("1");
$sog->setCustomerIdentifier("09900243773");
$sog->setCustomerExtraIdentifier("123456");
$sog->setCustomerName("Teste");
$sog->setEmail("teste@teste.com.br");
$sog->setCustomerBillingAddress("Rua teste número 368");
$sog->setCustomerShippingAddress("Rua teste número 368");
var_dump($sog->enviarDados($dados_loja));
?>
Quando eu mando rodar o web_service.php, fica um tempão rodando e no fim não aparece nada na tela. Nem erro nem nada. O que está faltando ou errado ? Desde já agradeço.
Pergunta
Renato Penna
Boa tarde a todos. Eu estou tentando fazer um webservice com WSDL. Porém eu nunca fiz isso e não está funcionando. Alguém pode me ajudar ? Eu fiz estes arquivos:
Loja.php
<?php class Loja { private $proxy; private $sessionId; private $atributeSets; private $set; private $caracteristicas; function getProxy() { return $this->proxy; } function setProxy($value) { $this->proxy = $value; } function getSessionId() { return $this->sessionId; } function setSessionId($value) { $this->sessionId = $value; } function getAtributeSets() { return $this->atributeSets; } function setAtributeSets($value) { $this->atributeSets = $value; } function getSet() { return $this->set; } function setSet($value) { $this->set = $value; } function getCaracteristicas() { return $this->caracteristicas; } function setCaracteristicas($value) { $this->caracteristicas = $value; } function pegarDados() { $proxy = new SoapClient('http://manutencao.workcopy.lojasingular.com.br/api/soap/?wsdl'); //$this->setProxy(new SoapClient('http://manutencao.workcopy.lojasingular.com.br/api/soap/?wsdl')); $sessionId = $proxy->login('jefersonsilva', '123456'); //$this->setSessionId($this->getProxy()->login('jefersonsilva', '123456')); $atributeSets = $proxy->call($sessionId, 'product_attribute_set.list'); //$this->setAtributeSets($this->getProxy()->call($sessionId, 'product_attribute_set.list')); $set = current($atributeSets); //$this->setSet(current($this->getAtributeSets())); $caracteristicas = $proxy->call($sessionId, 'sales_order.list', array(array('state'=>array('eq'=>'processing')))); //$this->setCaracteristicas($this->getProxy()->call($sessionId, 'sales_order.list', array(array('state'=>array('eq'=>'processing'))))); for($i=0;$i<count($caracteristicas);$i++) { $dados_loja = $proxy->call($sessionId, 'sales_order.info',$caracteristicas[$i]["increment_id"]); } return $dados_loja; /* $vet_caracteristicas = $this->getCaracteristicas(); for($i=0;$i<count($this->getCaracteristicas());$i++) { $dados_loja = $this->getProxy()->call($sessionId, 'sales_order.info',$vet_caracteristicas[$i]["increment_id"]); } return $vet_caracteristicas; */ } } ?>Sog.php<?php class Sog { private $username; private $password; private $customerType; private $customerIdentifier; private $customerExtraIdentifier; private $customerName; private $customerEmail; private $customerBillingAddress; private $customerShippingAddress; private $sogob; function getUsername() { return $this->username; } function setUsername($value) { $this->username = $value; } function getPassword() { return $this->password; } function setPassword($value) { $this->password = $value; } function getCustomerType() { return $this->customertype; } function setCustomerType($value) { $this->customerType = $value; } function getCustomerIdentifier() { return $this->customeridentifier; } function setCustomerIdentifier($value) { $this->customerIdentifier = $value; } function getCustomerExtraIdentifier() { return $this->customerExtraIdentifier; } function setCustomerExtraIdentifier($value) { $this->customerExtraIdentifier = $value; } function getCustomerName() { return $this->customerName; } function setCustomerName($value) { $this->customerName = $value; } function getEmail() { return $this->customerEmail; } function setEmail($value) { $this->customerEmail = $value; } function getCustomerBillingAddress() { return $this->customerBillingAddress; } function setCustomerBillingAddress($value) { $this->customerBillingAddress = $value; } function getCustomerShippingAddress() { return $this->customerShippingAddress; } function setCustomerShippingAddress($value) { $this->customerShippingAddress = $value; } function enviarDados($dl) { $this->sogob = new SoapClient("http://lajedo.singulardigital.com.br:6060/sog/services/orderWS?wsdl"); $sessionId = $this->sogob->login($this->getUsername(), $this->getPassword()); $lines = NULL; foreach($dl as $item) { $lines[] = Array( "isbn" => $item["sku"], "quantity" => $item["qty_ordered"], "price" => $item["price"] ); } $params = Array( "username" => $this->getUsername(), "password" => $this->getPassword(), "customerType" => $this->getCustomerType(), "customerIdentifier" => $this->getCustomerIdentifier(), "customerExtraIdentifier" => $this->getCustomerExtraIdentifier(), "customerName" => $this->getCustomerName(), "customerEmail" => $this->getEmail(), "customerBillingAddress" => (Object) $this->getCustomerBillingAddress(), "customerShippingAddress" => (Object) $this->getCustomerBillingAddress(), "partnerOrderId" => $dl->sku, "shippingPrice" => $dl->shipping_amount, "lines" => $lines); /* $params = Array( "username" => $this->username, "password" => $this->password, "customerType" => $this->customerType, "customerIdentifier" => $this->customerIdentifier, "customerExtraIdentifier" => $this->customerExtraIdentifier, "customerName" => $this->customerName, "customerEmail" => $this->customerEmail, "customerBillingAddress" => (Object) $this->customerBillingAddress, "customerShippingAddress" => (Object) $this->customerBillingAddress, "partnerOrderId" => $dados->numeroDoPedido, "shippingPrice" => $dados->frete, "lines" => $lines ); */ $dados_envio = $this->sogob->catalogStoredOrder($params); return $dados_envio; } } ?>web_service.php<?php include("loja.php"); include("sog.php"); $loja = new Loja(); $sog = new Sog(); $dados_loja = $loja->pegarDados(); $sog->setUsername("aaaa"); $sog->setPassword("bbbb123456"); $sog->setCustomerType("1"); $sog->setCustomerIdentifier("09900243773"); $sog->setCustomerExtraIdentifier("123456"); $sog->setCustomerName("Teste"); $sog->setEmail("teste@teste.com.br"); $sog->setCustomerBillingAddress("Rua teste número 368"); $sog->setCustomerShippingAddress("Rua teste número 368"); var_dump($sog->enviarDados($dados_loja)); ?>Quando eu mando rodar o web_service.php, fica um tempão rodando e no fim não aparece nada na tela. Nem erro nem nada. O que está faltando ou errado ? Desde já agradeço.
Link para o comentário
Compartilhar em outros sites
2 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.