Magento SOAP API - Invalid XML fault(reindex()) - magento

I implemented a reindex API call. For an category index, it works as expected. For a product index (which takes about 3 min. to process), a process is started, but after approx. 45 seconds, I get a response "Invalid XML".
As it looks like, there is a problem of execution time. I did change a parameter max_execution_time to 600 (seconds). I enabled logging, but get no exception or error. In index management GUI, I see that reindex process started and is finished successfully 2 minutes after a response (Invalid XML) is returned (total reindex time is approx. 3 min).
A code of an API looks ok, because I can update all indexes, except product price and product flat data.
Any idea?
using wireshark:
Request:
POST /index.php/api/v2_soap/index/ HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.3053)
VsDebuggerCausalityData: uIDPo6o2uSDL0oVKpqKJjDrFPsEAAAAAJt2oK8A51UOeAJsKkziyy/q2t81fNIxMnAvF+VaT7jIACQAA
Content-Type: text/xml; charset=utf-8
SOAPAction: "urn:Mage_Api_Model_Server_V2_HandlerAction"
Host: XXXXXXXXXXX(hidden for a security reason
Content-Length: 609
Expect: 100-continue
HTTP/1.1 100 Continue
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="urn:Magento" xmlns:types="urn:Magento/encodedTypes"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<tns:iwCoreIndexingReindexById>
<sessionId xsi:type="xsd:string">835cfa019572c1a893b3799eecbc6903</sessionId>
<indexId xsi:type="xsd:int">4</indexId>
</tns:iwCoreIndexingReindexById>
</soap:Body>
</soap:Envelope>
Response(after 39 seconds!)
HTTP/1.1 500 Internal Service Error
Date: Fri, 18 May 2012 20:50:22 GMT
Server: Apache
X-Powered-By: PHP/5.2.17
Content-Length: 269
Connection: close
Content-Type: text/xml; charset=utf-8
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>Sender</faultcode>
<faultstring>Invalid XML</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
State of index is processing. So a call is invoked and an action is also in a progress. Api.php looks like(this code is execuded and no exception is logged):
public function indexingReindexById( $indexId ){
$process = Mage::getModel('index/process')->load($indexId);
try{
$process->reindexAll();
} catch(exception $e){
Mage::Log($e->getMessage());
return false;
}
return true;
}

Changing a provider did a job. So it was a server issue.

Related

Problems with Autodiscover request : 'GetUserSettings'

The request to
POST autodiscover-s.outlook.com/autodiscover/autodiscover.xml
Content-Type: text/xml; charset=utf-8
Accept: text/xml; charset=utf-8
BODY
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:a="http://schemas.microsoft.com/exchange/2010/Autodiscover"
xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<a:RequestedServerVersion>Exchange2010</a:RequestedServerVersion>
<wsa:Action>http://schemas.microsoft.com/exchange/2010/Autodiscover/Autodiscover/GetUserSettings</wsa:Action>
<wsa:To>https://outlook.com/autodiscover/autodiscover.svc</wsa:To>
</soap:Header>
<soap:Body>
<a:GetUserSettingsRequestMessage xmlns:a="http://schemas.microsoft.com/exchange/2010/Autodiscover">
<a:Request>
<a:Users>
<a:User>
<a:Mailbox>test#test_test.onmicrosoft.com</a:Mailbox>
</a:User>
</a:Users>
<a:RequestedSettings>
<a:Setting>UserDisplayName</a:Setting>
<a:Setting>UserDN</a:Setting>
<a:Setting>UserDeploymentId</a:Setting>
<a:Setting>InternalMailboxServer</a:Setting>
<a:Setting>MailboxDN</a:Setting>
<a:Setting>ActiveDirectoryServer</a:Setting>
<a:Setting>CasVersion</a:Setting>
<a:Setting>EwsSupportedSchemas</a:Setting>
</a:RequestedSettings>
</a:Request>
</a:GetUserSettingsRequestMessage>
</soap:Body>
</soap:Envelope>
I got the response :
<?xml version="1.0" encoding="utf-8"?>
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">
<Response>
<Error Time="16:03:30.0909591" Id="4042903973">
<ErrorCode>600</ErrorCode>
<Message>Invalid Request</Message>
<DebugData />
</Error>
</Response>
</Autodiscover>
I do not know what is wrong. I tried a lot of endpoints and different schemas in the body, but still nothing. Can anyone help me with solving such a problem?
Your submitting a SOAP request to the POX (Plain old XML endpoint) you need to submit the SOAP request to autodiscover-s.outlook.com/autodiscover/autodiscover.svc which is the SOAP endpoint.
I've test your code.
Did you valid your parameter for this?
<a:Users>
<a:User>
<a:Mailbox>test#test_test.onmicrosoft.com</a:Mailbox>
</a:User>
</a:Users>
<a:RequestedSettings>
<a:Setting>UserDisplayName</a:Setting>
<a:Setting>UserDN</a:Setting>
<a:Setting>UserDeploymentId</a:Setting>
<a:Setting>InternalMailboxServer</a:Setting>
<a:Setting>MailboxDN</a:Setting>
<a:Setting>ActiveDirectoryServer</a:Setting>
<a:Setting>CasVersion</a:Setting>
<a:Setting>EwsSupportedSchemas</a:Setting>
</a:RequestedSettings>
</a:Request>
If your request parameter correct, you can refer to this link:
Quick way to Fix AutoDiscover Error Code 600 in Exchange

unable to make a remote POST to Web API (sending string) - not sure what happens

I have a web api method:
[HttpPost]
public IActionResult Post([FromBody]string entryInJson)
{ .... }
This method is hit by a remote domain, so CORS is needed. As i wasn't successful in finding the relevant cs file in my mvc6 app, i used this solution in web.config:
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
When I do the post, using online tools like http://requestmaker.com/, i am getting this:
Request Headers Sent:
POST /api/Entries/ HTTP/1.1
Host: justalk.tukuoro.com
Accept: */*
Content-Type: text/plain
Content-Length: 179
Response Headers:
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 0
Expires: -1
Location: https://justalk.tukuoro.com/Account/Login?ReturnUrl=%2FHome%2FError
X-Powered-By: ASP.NET
Access-Control-Allow-Origin: *
Date: Mon, 16 May 2016 05:25:53 GMT
Now, it seems like it is trying to redirect me (302) but to the error page, and it is not sending anything back from the post method, which returns:
return new ObjectResult(true);
I am not sure what is going on:
Am I getting to the right controller? i have code that is supposed to log the incoming string but it does not create the log.
If it is not working? why? is the response header telling me something I don't understand?
Am I doing it right?
thank you for your time!
if you want send json post request this entryInJson must be object type not string
for example
[HttpPost]
public IActionResult Post([FromBody]EntryInJson entryInJson)
{ .... }
chat comment
the code doing the http request to my post method - how does it convert this class "RemoteEntry" to JSON data
http://www.newtonsoft.com/json/help/html/serializingjson.htm
Update :
302 is not an error but a redircet to a tempoaray location. you could resend the request to the new location received in the response header.
and it's propably a server misconfiguration issue then.
modSecurity firewall blocking your requests an making automatics redirections (302).

Creating Google Group contact

I am trying to create a group contact using Google Contacts v3.
Following the example, and testing within the OAuth 2.0 Playground, here is my sample code:
POST /m8/feeds/groups/default/full/ HTTP/1.1
Host: www.google.com
Gdata-version: 3.0
Content-length: 355
Content-type: application/atom+xml
Authorization: Bearer #{auth_code_goes_in_here}#
<atom:entry xmlns:gd="http://schemas.google.com/g/2005">
<atom:category scheme="http://schemas.google.com/g/2005#kind"
term="http://schemas.google.com/contact/2008#group"/>
<atom:title type="text">Salsa group</atom:title>
<gd:extendedProperty name="more info about the group">
<info>Nice people.</info>
</gd:extendedProperty>
</atom:entry>
However, I keep getting the 400 error in the response:
HTTP/1.1 400 Bad Request
Alternate-protocol: 443:quic,p=1
Content-length: 236
X-xss-protection: 1; mode=block
X-content-type-options: nosniff
Transfer-encoding: chunked
Expires: Fri, 11 Mar 2016 05:18:06 GMT
Vary: Origin, X-Origin
Server: GSE
-content-encoding: gzip
Cache-control: private, max-age=0
Date: Fri, 11 Mar 2016 05:18:06 GMT
X-frame-options: SAMEORIGIN
Alt-svc: quic=":443"; ma=2592000; v="31,30,29,28,27,26,25"
Content-type: application/vnd.google.gdata.error+xml; charset=UTF-8
<?xml version="1.0" encoding="UTF-8"?>
<errors xmlns="http://schemas.google.com/g/2005">
<error>
<domain>GData</domain>
<code>invalid</code>
<internalReason>Entry does not have any fields set</internalReason>
</error>
</errors>
Any ideas what I am doing wrong here?
Further to this, I would like to create contacts in Google, with specific Group attached to it. Is this do-able from the 'creating contacts' method? I can't seem to find an example where I can specify the group directly to it.
Thanks for any suggestions.
Regards,
Leroy
After some painful research, I found the solution by changing the data from:
<atom:entry xmlns:gd="http://schemas.google.com/g/2005">
to
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005">

Can't configure $batch endpoint for OData Web service exposed with ASP .Net Web Api to Lightswitch

I have a problem of setting up an OData web service with ASP .NET Web API. I need to provide that service as a data source to Lightswitch. Get requests work normally but when I try POST - this is where I got stuck.
The Error
In Lightswitch I get the error:
{"Message":"The batch request must have 'multipart/mixed' as the media type."}
when invoking an add/edit command.
As Lightswitch requires $batch endpoint, I installed the latest RC version of Web API that supports them. Also before starting to configure the batch end point I followed the tutorials at: http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api
Then I followed this tutorial to setup the batch endpoint: https://aspnetwebstack.codeplex.com/wikipage?title=Web%20API%20Request%20Batching
I reviwed this post: How to create / where the batch endpoint is for an asp.net OData webservice and managed to make the project compile with DefaultODataBatchHandler. Still I can't make batch requests/response work.
Details of the scenario I tried:
Request/Responce - data from Fiddler
Request sent from Lightswich Client:
POST http://localhost:3352/ContainerData.svc/$batch HTTP/1.1
DataServiceVersion: 1.0
Accept: multipart/mixed
Content-Type: multipart/mixed;boundary=batch_730c-bd5b-40de
MaxDataServiceVersion: 3.0
Referer: http://localhost:3352/HTMLClient/
Accept-Language: en-GB
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)
Connection: Keep-Alive
Content-Length: 535
DNT: 1
Host: localhost:3352
Pragma: no-cache
--batch_730c-bd5b-40de
Content-Type: multipart/mixed; boundary=changeset_2952-4c78-0ea1
--changeset_2952-4c78-0ea1
Content-Type: application/http
Content-Transfer-Encoding: binary
POST ServiceProviders HTTP/1.1
Content-ID: 0
Accept: application/atomsvc+xml;q=0.8, application/json;odata=verbose;q=0.5, */*;q=0.1
DataServiceVersion: 1.0
Content-Type: application/json
MaxDataServiceVersion: 3.0
{"ID":2,"CategoryID":1,"Name":"fdfdrer","Description":"fefdf"}
--changeset_2952-4c78-0ea1--
--batch_730c-bd5b-40de--
Responce of Web API:
HTTP/1.1 202 Accepted
Cache-Control: no-cache
Content-Length: 2886
Content-Type: multipart/mixed; boundary=batchresponse_663f69c3-6315-447b-b179-00bf407c3b09
Server: Microsoft-IIS/8.0
X-Content-Type-Options: nosniff
DataServiceVersion: 1.0;
X-AspNet-Version: 4.0.30319
X-SourceFiles: =?UTF-8?B?QzpcVXNlcnNcdmd0MWcxMlxEb2N1bWVudHNcVmlzdWFsIFN0dWRpbyAyMDEyXFByb2plY3RzXE1ha2VZb3VyQ2hvaWNlXE1ha2VZb3VyQ2hvaWNlVUlcTWFrZVlvdXJDaG9pY2VVSVxCaW5cRGVidWdcQ29udGFpbmVyRGF0YS5zdmNcJGJhdGNo?=
X-Powered-By: ASP.NET
Date: Fri, 05 Jul 2013 11:01:49 GMT
--batchresponse_663f69c3-6315-447b-b179-00bf407c3b09
Content-Type: multipart/mixed; boundary=changesetresponse_d1537003-f0cd-4fe2-b4b1-2f562b3179d0
--changesetresponse_d1537003-f0cd-4fe2-b4b1-2f562b3179d0
Content-Type: application/http
Content-Transfer-Encoding: binary
HTTP/1.1 500 Internal Server Error
Content-ID: 0
X-Content-Type-Options: nosniff
Cache-Control: no-cache
DataServiceVersion: 1.0;
Content-Type: application/json;odata=verbose;charset=utf-8
{"error":{"code":"1","message":{"lang":"en-GB","value":"<?xml version=\"1.0\" encoding=\"utf-16\"?><ExceptionInfo><Message>One or more of the changes failed to save. To ensure consistency, refresh and re-apply your changes.\r\nInner exception message:\r\nAn error occurred while processing this request.\r\nInner exception message:\r\n{\"Message\":\"The batch request must have 'multipart/mixed' as the media type.\"}</Message><StackTrace>
at Microsoft.LightSwitch.ServerGenerated.Implementation.DataProvider.AstoriaDataServiceDataProvider.<>c__DisplayClass1.<SubmitCore>b__0()\r\n
at Microsoft.LightSwitch.ServerGenerated.Implementation.DataProvider.AstoriaDataServiceDataProvider.InvokeAstoriaOperation(DataServiceContext context, Action astoriaOperation)\r\n
at Microsoft.LightSwitch.ServerGenerated.Implementation.DataProvider.AstoriaDataServiceDataProvider.SubmitCore(IEnumerable`1 changes)\r\n
at Microsoft.LightSwitch.ServerGenerated.Implementation.DataProvider.DataProvider.Submit(IEnumerable`1 changes)\r\n
at Microsoft.LightSwitch.ServerGenerated.Implementation.DataServiceImplementation`1.PerformPersistCore(IEnumerable`1 eventsChangeSetItems)\r\n
at Microsoft.LightSwitch.ServerGenerated.Implementation.DataServiceImplementation`1.<>c__DisplayClass46.<PerformPersist>b__45()\r\n
at Microsoft.LightSwitch.Threading.DualDispatcherObject.Mutate(IDispatcher logicDispatcher, MutatorHost host, Action mutator)\r\n
at Microsoft.LightSwitch.ServerGenerated.Implementation.DataServiceImplementation`1.PerformPersist(IEnumerable`1 eventsChangeSetItems)\r\n
at Microsoft.LightSwitch.ServerGenerated.Implementation.DataServiceImplementation`1.Microsoft.LightSwitch.ServerGenerated.Implementation.IServerDataServiceImplementationCore.Submit()\r\n
at Microsoft.LightSwitch.ServerGenerated.Implementation.DataService`1.<>c__DisplayClasse.<Microsoft.LightSwitch.ServerGenerated.Implementation.IODataService.SaveChanges>b__c()\r\n
at Microsoft.LightSwitch.ServerGenerated.Implementation.DataServiceImplementation`1.InvokeOperationCore[T](String operationName, Object[] args, Boolean invokedFromODataClient, Func`1 invokeOperation, Action catchCallback, Action`2 serializeCustomExceptionInfo)</StackTrace><ErrorInfo /></ExceptionInfo>"}}}
--changesetresponse_d1537003-f0cd-4fe2-b4b1-2f562b3179d0--
--batchresponse_663f69c3-6315-447b-b179-00bf407c3b09--
Log from Web API:
iisexpress.exe Information: 0 : Request, Method=POST, Url=http://localhost:3346/odata/$batch, Message='http://localhost:3346/odata/$batch'
iisexpress.exe Information: 0 : Request, Method=POST, Url=http://localhost:3346/odata/ServiceProviders, Message='http://localhost:3346/odata/ServiceProviders'
iisexpress.exe Information: 0 : Message='Will use same 'JsonMediaTypeFormatter' formatter', Operation=JsonMediaTypeFormatter.GetPerRequestFormatterInstance
iisexpress.exe Information: 0 : Message='Selected formatter='JsonMediaTypeFormatter', content-type='application/json; charset=utf-8'', Operation=DefaultContentNegotiator.Negotiate
iisexpress.exe Information: 0 : Operation=InspectHandler.SendAsync, Status=400 (BadRequest)
iisexpress.exe Information: 0 : Response, Status=400 (BadRequest), Method=POST, Url=http://localhost:3346/odata/ServiceProviders, Message='Content-type='application/json; charset=utf-8', content-length=unknown'
iisexpress.exe Information: 0 : Operation=InspectHandler.SendAsync, Status=202 (Accepted)
iisexpress.exe Information: 0 : Response, Status=202 (Accepted), Method=POST, Url=http://localhost:3346/odata/$batch, Message='Content-type='multipart/mixed; boundary=batchresponse_580061e2-8dc6-4676-b207-1b6ad0ff8847', content-length=unknown'
iisexpress.exe Information: 0 : Operation=JsonMediaTypeFormatter.WriteToStreamAsync

Ruby: Savon SOAP Requests receives 400 and 415 errors

I am trying to make a SOAP request using the ruby library Savon.
I am using the following code:
require "savon"
Savon.configure do |config|
config.soap_version = 2 # use SOAP 1.2
config.raise_errors = false
end
wsdl_logon = Savon::Client.new do
wsdl.document = "https://api.affili.net/V2.0/Logon.svc?wsdl"
end
username = 'XXX'
password = 'YYY'
wsdl_logon.http.headers["Content-Type"] = "text/xml; charset=utf-8"
response = wsdl_logon.request "Logon" do
soap.body = {'Username' => username, 'Password' => password, 'WebServiceType' => 'Product'}
end
if response.http_error?
puts "Http Error!"
puts y response.http_error
else
puts "No Http Error!"
end
But I keep receiving 400 error messages ("bad request"). Or, if I remove the following line
wsdl_logon.http.headers["Content-Type"] = "text/xml; charset=utf-8"
I am receiving 415 error messages ("unsupported media type").
I have been using PHP to make these requests until now, and the following code always worked without problems:
$soap_logon = new SoapClient('https://api.affili.net/V2.0/Logon.svc?wsdl');
$token = $soap_logon->Logon(array(
'Username' => 'XXX',
'Password' => 'YYY',
'WebServiceType' => 'Product'
));
Can anybody point me to the right direction what a possible error source might be? I am completely lost right now.
Thank you for your help.
I did as Tom De Leu suggested, and tried to remove as many differences in the generated SOAP requests in question as possible. But I still keep receiving 400 errors. Any hint on possible reasons for this would be highly appreciated.
This is the (working) Request generated by PHP (linebreaks in XML added for clarity):
POST /V2.0/Logon.svc HTTP/1.1
Host: api.affili.net
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.2.0-8+etch16
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://affilinet.framework.webservices/Svc/ServiceContract1/Logon"
Content-Length: 456
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://affilinet.framework.webservices/types"
xmlns:ns2="http://affilinet.framework.webservices/Svc"
>
<SOAP-ENV:Body>
<ns2:LogonRequestMsg>
<ns1:Username>xxx</ns1:Username>
<ns1:Password>yyy</ns1:Password>
<ns1:WebServiceType>Product</ns1:WebServiceType>
</ns2:LogonRequestMsg>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
This is the (not working) request generated by Ruby (again, xml linebreaks added for clarity)
SOAP request: https://api.affili.net/V2.0/Logon.svc
Content-Type: text/xml; charset=utf-8, SOAPAction: http://affilinet.framework.webservices/Svc/ServiceContract1/Logon, Content-Length: 605
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wsdl="http://affilinet.framework.webservices/Svc"
SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://affilinet.framework.webservices/types"
xmlns:ns2="http://affilinet.framework.webservices/Svc"
>
<SOAP-ENV:Body>
<ns2:LogonRequestMsg>
<ns1:Username>XXX</ns1:Username>
<ns1:Password>YYY</ns1:Password>
<wsdl:WebServiceType>Product</wsdl:WebServiceType>
</ns2:LogonRequestMsg>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
HTTPI executes HTTP POST using the httpclient adapter
SOAP response (status 400):
I found that I needed to add the headers in to get past the 415 error.
Savon.client(wsdl: "www.sample_doman.com/endpoint?wsdl", headers: {'Content-Type' => 'application/soap+xml; charset=utf-8'})
I would suggest looking at the XML sent by the PHP code, then comparing it with the XML sent by the Ruby Savon code, and check where the differences are. Then see whether you can modify your ruby code to generate the correct request.
Telling Savon to use SOAP version 2 (really 1.2) and then manually setting the content type to text/xml kind of defeats the purpose.
If your web service requires SOAP 1.2, then it is expecting a content type of 'application/soap+xml', which SAVON will do for you if you set the soap_version to 2.
If you want a content type of text/xml, just set your soap_version config variable to 1

Resources