I'm trying to consume a method, but it returns me that Login failed, but in SOAPUI it works normally.
I think the error is in the array I'm sending.
Is this my array compared to XML is correct?
XML:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:int="https://product.net" xmlns:trav="http://schemas.datacontract.org/2004/07/Product.Report" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<soapenv:Header/>
<soapenv:Body>
<int:Product>
<int:request>
<trav:Color>
<arr:int>3</arr:int>
<arr:int>5</arr:int>
</trav:Color>
<trav:Cod>1</trav:Cod>
<trav:Price>
<arr:string>1.50</arr:string>
<arr:string>9.00</arr:string>
</trav:Price>
<trav:Size>G</trav:Size>
</int:request>
<int:Login>
<trav:Pass>123456</trav:Pass>
<trav:User>user123</trav:User>
</int:Login>
</int:Product>
</soapenv:Body>
</soapenv:Envelope>
My array:
$consume->xmlArray = array(
"request" => array(
"Color" => array(
array(
"int" => '3'
),
array(
"int" => '5'
)
),
"Cod" => "1",
"Price" => array(
array(
"string" => "1.50"
),
array(
"string" => "9.00"
),
),
"Size" => "G"
),
"Login" => array(
"Pass" => "123456",
"User" => "user123"
)
);
Return:
Fatal error: Uncaught SoapFault exception: [s:Client] Login Failed. in /var/www/html/Consume.php:85
Function Class Cosume:
public function Product(){
$client = new SoapClient( $this->wsdl_url, array( "trace" => 1 ) );
$params = $this->xmlArray;
$response = $client->Product($params);
return $response;
}
Related
$data = array(
'uid' => 'key',
'zip' => 'STRING_VARIABLE',
"school" => array(
array("sid" => "STRING_VARIABLE", "qty" => NUMERIC_VARIABLE),
array("strSrchSchool" => array(
"name" => "STRING_VARIABLE",
"address" => "STRING_VARIABLE",
),
"students" => NUMERIC_VARIABLE)
),
"sort" => "default"
);
Above array is a part of API call. I want dynamic values at places where I have mentioned 'STRING_VARIABLE' & 'NUMERIC_VARIABLE'. So I want to write PHP variables there and tried few different things of concatenation but none is working.
When I call API With different tries for above PHP variables, it gives below error.
array(2) { ["status"]=> string(5) "error" ["error"]=> string(62) "Error parsing JSON object, check format and object definition." }
So please let me know what is correct method to write PHP variable directly at above mentioned places when creating PHP array.
You don't have to do anything special.
Just write the name of the variable.
$zip = '252354';
$data = array(
'uid' => 'key',
'zip' => $zip,
"school" => array(
array("sid" => "STRING_VARIABLE", "qty" => NUMERIC_VARIABLE),
array("strSrchSchool" => array(
"name" => "STRING_VARIABLE",
"address" => "STRING_VARIABLE",
),
"students" => NUMERIC_VARIABLE)
),
"sort" => "default"
);
And so on you can write as many variables inside the array as you wish.
i try to create orders with CreateOrder method in soap web service:
http://80.72.84.109/MW/services/bilkiservice.asmx?wsdl
with this simple code:
$soap = new SoapClient(MW_SOAP_URL, array(
"trace" => 1,
"exceptions" => 1
));
//set headers
$headerbody = array(
'Database' => MW_DATABASE,
'Username' => MW_USERNAME,
'Password' => MW_PASSWORD
);
$ns = 'http://tempuri.org/';
$header = new SoapHeader($ns, 'AuthenticationHeader', $headerbody);
$this->soap->__setSoapHeaders($header);
$orderInfo = array(
'OrderNumber' => 23344,
'Email' => 'test#test.com',
'Delivery' => array(
'Name' => 'Peter',
'City' => 'LA',
'Post' => 1000,
'Address' => 'Test Street 1',
'Email' => 'test#test.com',
'Phone' => '12345'
),
'PaymentType' => 2,
'Items' => array(
'OrderItem' => array(
'Code' => 3479,
'Quantity' => 1,
'TotalPrice' => 2.73
)
)
);
$soap->CreateOrder($orderInfo);
But i always get this error:
object(stdClass)#5 (1) { ["CreateOrderResult"]=> object(stdClass)#6 (4)
{ ["ErrorMessage"]=> string(53) "Object reference not set to an instance of an object."
["ErrorCode"]=> int(-1) ["Errs"]=> object(stdClass)#7 (0) { } ["OrderID"]=> int(0) } }
I successfully create new contragent with the other method CreateContragent, but CreateOrder didn't work.
May be the array data is wrong? But I tried many configurations and nothing works.
it is not your fault, your web-services didn't work. that is your CreatingOrder function's result description :
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<CreateOrderResponse xmlns="http://tempuri.org/">
<CreateOrderResult>
<Errs>
<ErrorItem>
<ErrorCode>int</ErrorCode>
<ErrorMessage>string</ErrorMessage>
<ItemNumber>int</ItemNumber>
</ErrorItem>
<ErrorItem>
<ErrorCode>int</ErrorCode>
<ErrorMessage>string</ErrorMessage>
<ItemNumber>int</ItemNumber>
</ErrorItem>
</Errs>
<OrderID>int</OrderID>
</CreateOrderResult>
</CreateOrderResponse>
</soap:Body>
</soap:Envelope>
I want to send the below object using soap with php SoapClient.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:adin="http://3e.pl/ADInterface">
<soapenv:Header/>
<soapenv:Body>
<adin:queryData>
<adin:ModelCRUDRequest>
<adin:ModelCRUD>
<adin:serviceType>ReadSalesOrder</adin:serviceType>
<adin:TableName>XX_RV_Interface_Order</adin:TableName>
<adin:RecordID>0</adin:RecordID>
<adin:Filter></adin:Filter>
<adin:Action>Read</adin:Action>
<!--Optional:-->
<adin:DataRow>
<!--Zero or more repetitions:-->
<adin:field type="integer" column="C_BPartner_ID" lval="" disp="" edit="" error="" errorVal="">
<adin:val>1000643</adin:val>
</adin:field>
</adin:DataRow>
</adin:ModelCRUD>
<adin:ADLoginRequest>
<adin:user>username</adin:user>
<adin:pass>password</adin:pass>
<adin:lang>zh_CN</adin:lang>
<adin:ClientID>1000000</adin:ClientID>
<adin:RoleID>1000029</adin:RoleID>
<adin:OrgID>1000000</adin:OrgID>
<adin:WarehouseID>1000023</adin:WarehouseID>
</adin:ADLoginRequest>
</adin:ModelCRUDRequest>
</adin:queryData>
</soapenv:Body>
</soapenv:Envelope>
I have tried the below:
$wsdl = 'http://example.com/ModelADService?wsdl';
$client = new SoapClient($wsdl);
$result = $client->__soapCall('queryData', array(
'ModelCRUDRequest' => array(
'ModelCRUD' => array(
'serviceType' => 'ReadSalesOrder',
'TableName' => 'XX_RV_Interface_Order',
'RecordID' => 0,
'Filter' => '',
'Action' => 'Read',
'DataRow' => array(
'field' => array(
'type' => 'integer',
'column' => 'C_BPartner_ID',
'lval' => '',
'disp' => '',
'edit' => '',
'error' => '',
'errorVal' => '',
'val' => 1000643,
)
)
),
'ADLoginRequest' => array(
'user' => 'username',
'pass' => 'password',
'lang' => 'zh_CN',
'ClientID' => 1000000,
'RoleID' => 1000029,
'OrgID' => 1000000,
'WarehouseID' => 1000023,
'stage' => '',
),
),
));
var_dump($result);
Fatal error: Uncaught SoapFault exception: [soap:Client] Parameter ModelCRUDRequest does not exist!
SOAP Client must be initialized before
$client = new SoapClient($wsdl);
You're problem isn't with the soap call, but with the data you're sending or the receiving soap. soap is frustrating because you're calling a function on another server, and any errors thrown on that server trigger on your server. So if their function has a fatal error, your code will have a fatal error. This is why all soap calls must be inside a try catch.
i want to make a SOAP request to the server. But i'm struggling with an error.
This is how the XML should look like:
<ExternalOrder Ref="85" Version="2">
<Orders>
<Order Operation="Add" Client="1">
<Item Operation="Add">
<ItemId>244</ItemId>
<Description>coke</Description>
<Quantity>2</Quantity>
<Price>1.75</Price>
</Item>
</Order>
</Orders>
</ExternalOrder>
Here is my PHP code:
http://11.30.11.151/ProxyWebService/ProxyService.asmx?WSDL', array('trace' => true));
$result = $client->__soapCall('AddOrder', array(
'ExternalOrder' => [
'Orders' => [
'Order' => [
'Item' => [
'ItemId' => '244',
'Description' => 'coke',
'Quantity' => '2',
'Price' => '1.75'
],
]
]
]
));
?>
Server response: Object reference not set to an instance of an object.
I'm having a problem with a soapclient call. The soaprequest has to look like:
<eng:Compose>
<!--Optional:-->
<EWSComposeRequest>
<!--Optional:-->
<driver>
<!--Optional:-->
<driver>base64</driver>
<!--Optional:-->
<fileName>INPUT</fileName>
</driver>
<engineOptions>
<name>FILEMAP</name>
<value>DLFOUT.dlf,dummy.dlf</value>
</engineOptions>
<engineOptions>
<name>FILEMAP</name>
<value>PDFOUT.pdf,dummy.pdf</value>
</engineOptions>
<engineOptions>
<name>RUNMODE</name>
<value>PRODUCTION</value>
</engineOptions>
<!--Optional:-->
<fileReturnRegEx>^.*.(dlf|pdf)$</fileReturnRegEx>
<includeHeader>True</includeHeader>
<includeMessageFile>True</includeMessageFile>
<!--Optional:-->
<pubFile>TestLive.pub</pubFile>
</EWSComposeRequest>
</eng:Compose>
My soap_param is:
$soap_param = array("Compose"=> array("EWSComposeRequest" =>
array( "driver" => array( "driver" => $post_Driver,
"fileName" => $post_FileName),
"engineOptions" => array( "name" => "KEY", "value" => $INI['encodedkey']),
"engineOptions" => array( "name" => "RUNMODE", "value" => $INI['runmode']),
"fileReturnRegEx" => $post_FileReturnRegEx, "includeHeader" => $post_IncludeHeader,
"includeMessageFile" => $post_IncludeMessage, "pubFile" => $post_PubFile)));
The soapcall appears to work, however.... I only reveive the last engineOptions element.
According to the xsd the element engineOptions can appear multiple times(0 to unbounded). Witin the soapcall this element seems to be overwritten. The index: engineOptions isn't unique.
I can't imagine that i am the only one facing this problem. I hope that there is a (simple) solution for this problem.
With special thanks to: András Szepesházi. The following $soap_param definition:
$soap_param => array(
'Compose' => array(
'EWSComposeRequest' => array(
'driver' => array(
'driver' => $post_Driver,
'fileName' => $post_FileName
),
'engineOptions' => array(
array(
'name' => 'KEY',
'value' => $INI['encodedkey']
),
array(
'name' => 'RUNMODE',
'value' => $INI['runmode']
),
array(
'name' => 'FILEMAP',
'value' => "DLFOUT.dlf,dummy.dlf"
),
array(
'name' => 'FILEMAP',
'value' => "PDFOUT.pdf,dummy.pdf"
),
),
'fileReturnRegEx' => $post_fileReturnPattern,
'includeHeader' => $post_IncludeHeader,
'includeMessageFile' => $post_IncludeMessage,
'pubFile' => $post_PubFile
)
)
);
Is able to create the following SOAP Request:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:hpexstream-services/Engine">
<SOAP-ENV:Header>
<ns1:n>n</ns1:n>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:Compose>
<EWSComposeRequest>
<driver>
<driver>base64</driver>
<fileName>INPUT</fileName>
</driver>
<engineOptions>
<name>KEY</name>
<value>base64</value>
</engineOptions>
<engineOptions>
<name>RUNMODE</name>
<value>PRODUCTION</value>
</engineOptions>
<engineOptions>
<name>FILEMAP</name>
<value>DLFOUT.dlf,dummy.dlf</value>
</engineOptions>
<engineOptions>
<name>FILEMAP</name>
<value>PDFOUT.pdf,dummy.pdf</value>
</engineOptions>
<includeHeader>true</includeHeader>
<includeMessageFile>true</includeMessageFile>
<pubFile>TestLive.pub</pubFile>
</EWSComposeRequest>
</ns1:Compose>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
So problem solved.