I'm trying to make an authentication to get some data from a client in Magento. I have valid access to do so, but always I am receiving the response "Session expired. Try to relogin". I am using both Advanced Rest Client with Chrome and
Rest Client with Mozila. I made a lot of requests to change my Token but the message is always the same.
<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:urn="urn:Magento">
<soapenv:Header/>
<soapenv:Body>
<urn:call soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<sessionid xsi:type="xsd:xxxxxxxxxxxxxxxxxxxxxxxxxxx</sessionid><resourcepath xsi:type="xsd:string">mobile.login</resourcepath><args soap-enc:arraytype="ns2:Map[1]" xsi:type="SOAP-ENC:Array"><item xsi:type="ns2:Map"><item><key xsi:type="xsd:string">email</key><value xsi:type="xsd:string">everton.com.br</value></item><item><key xsi:type="xsd:string">senha</key><value xsi:type="xsd:string">teste123</value></item></item></args>
</urn:call>
</soapenv:Body>
</soapenv:Envelope>
Thanks for help!!
Looks like we way you specify your sessionId is incorrect.
It should be
<sessionId xsi:type="xsd:string">xxxxxxxxxxxxxxxxxxxxxxxxxxx</sessionId>
Related
As a SOAP newbie I am following the same tutorial as given in Spring boot - Server did not recognize the value of HTTP Header SOAPAction. The tutorial can be found in https://howtodoinjava.com/spring-boot/spring-soap-client-webservicetemplate/amp/
Currently I am able to send the SOAP payload with the request needed. The server is responding to say I have not authenticated.
I therefore am trying to send the SOAP header with authentication detail along with this SOAP payload. See below examples.
Firstly, I have successfully managed to get the tutorial working. The request was sent with SOAP Action and response received.
Sent request [SaajSoapMessage {http://server.windeed.co.za/windeedengine/}CheckDeedsOfficeStatus]
The response is that I have not authenticated/sent authentication details correctly. I therefore created the Authentication Object with all the necessary details in order to marshall and make part of the SOAP message.
I tried the below:
ObjectFactory of = new ObjectFactory();
WinDeedCredentials cred = of.createWinDeedCredentials();
cred.setUsername("Test");
cred.setPassword("Test123");
cred.setCompany("COMPANY");
cred.setRequester("SOAP");
CheckDeedsOfficeStatus cdo = of.createCheckDeedsOfficeStatus();
CheckDeedsOfficeStatusResponse dr = (CheckDeedsOfficeStatusResponse)sc.callWebService(cdo,"http://server.windeed.co.za/windeedengine/CheckDeedsOfficeStatus");
The goal is to achieve this:
POST /windeedengine3/client.asmx HTTP/1.1
Host: server.windeed.co.za
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://server.windeed.co.za/windeedengine/CheckDeedsOfficeStatus"
<?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:Header>
<WinDeedCredentials xmlns="http://server.windeed.co.za/windeedengine/">
<Username>string</Username>
<Password>string</Password>
<Company>string</Company>
<Requester>string</Requester>
</WinDeedCredentials>
</soap:Header>
<soap:Body>
<CheckDeedsOfficeStatus xmlns="http://server.windeed.co.za/windeedengine/" />
</soap:Body>
</soap:Envelope>
Currently, with the missing Authentication details, I am told I haven't authenticated correctly.
The expected result is the correct response from the server: Online or Offline. What is the correct way?
I forgot to even revisit this topic. The problem was solved but I do not have the details immediately with me and need to travel to access them.
Prior to making the webservice call => sc.callWebService, it is important to inject the SOAP header details. I injected the xml header from SOAP UI into the code. Viola! It worked. Previously the MarshallSendAndReceive method was used with only the SoapActionCallback method. If I recall, I modified this to use WebServiceMessageCallback with an explicit definition of the xml header prior to making the webservice call.
I am attempting to create a meeting for a user with a room using the EWS api. When I send the below SOAP request, I receive the error "The specified folder could not be found in the store.". Is there anything wrong with the SOAP request, or is there anything that needs to be changed on the Exchange server?
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/messages">
<SOAP-ENV:Header>
<ns1:RequestServerVersion Version="Exchange2007"/>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns2:CreateItem SendMeetingInvitations="SendToAllAndSaveCopy">
<ns2:SavedItemFolderId>
<ns1:DistinguishedFolderId Id="calendar">
<ns1:Mailbox>
<ns1:EmailAddress>[useremail#website.com]</ns1:EmailAddress>
</ns1:Mailbox>
</ns1:DistinguishedFolderId>
</ns2:SavedItemFolderId>
<ns2:Items>
<ns1:CalendarItem>
<ns1:ItemClass>IPM.Appointment</ns1:ItemClass>
<ns1:Subject>Test</ns1:Subject>
<ns1:Sensitivity>Normal</ns1:Sensitivity>
<ns1:Importance>Normal</ns1:Importance>
<ns1:Start>2018-12-29T06:49:00+00:00</ns1:Start>
<ns1:End>2018-12-29T06:50:00+00:00</ns1:End>
<ns1:RequiredAttendees>
<ns1:Attendee>
<ns1:Mailbox>
<ns1:Name>Test user</ns1:Name>
<ns1:EmailAddress>[useremail#website.com]</ns1:EmailAddress>
<ns1:RoutingType>SMTP</ns1:RoutingType>
</ns1:Mailbox>
</ns1:Attendee>
</ns1:RequiredAttendees>
<ns1:Resources>
<ns1:Attendee>
<ns1:Mailbox>
<ns1:EmailAddress>[roomemail#website.com]</ns1:EmailAddress>
<ns1:RoutingType>SMTP</ns1:RoutingType>
</ns1:Mailbox>
</ns1:Attendee>
</ns1:Resources>
</ns1:CalendarItem>
</ns2:Items>
</ns2:CreateItem>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
That error indicates you don't have rights to the underlying calendar your trying to create the Appointment on. You would probably be better using EWS Impersonation in the senerio you describing as that will allows you to create the Appointment as the user (instead of On Behalf of) see https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-configure-impersonation
With you code you should be using Exchange2007
<SOAP-ENV:Header>
<ns1:RequestServerVersion Version="Exchange2007"/>
</SOAP-ENV:Header>
the RTM version of Exchange had a different Id format so i would suggest at least Exchange2007_SP1 or use the version you have the code working against see https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/ews-schema-versions-in-exchange
I've been trying to use Google's CardDAV APIs (and I've successfully gotten CalDAV access working). Unfortunately, I keep getting a 403 error when trying to discover the user's current-user-principal. FWIW, I have gone to Google's Developer Console and set up client information and it seems to work perfectly fine for CalDAV access.
Here is a snippet of the HTTP traffic for CardDAV:
PROPFIND https://www.googleapis.com:443/.well-known/carddav/
Depth: 0
Content-Type: text/xml
Brief: T
Authorization: Bearer ya29.1.AADtN_UD1CVKpIQPsyB4HzoKVxt4L5kPFXU3GucMTfJmJj9t0pzZqX1i3Xx748Y
<?xml version="1.0" encoding="utf-8"?>
<x0:propfind xmlns:x0="DAV:">
<x0:prop>
<x0:current-user-principal />
<x0:principal-URL />
<x0:resourcetype />
</x0:prop>
</x0:propfind>
vvvvvvvvvvvv
HTTP PROPFIND Status(403) Forbidden
<?xml version="1.0" encoding="UTF-8"?>
<errors xmlns="http://schemas.google.com/g/2005">
<error>
<domain>GData</domain>
<code>insufficientPermissions</code>
<internalReason>Insufficient Permission</internalReason>
</error>
</errors>
If anyone has some insight as to why this might be happening, it would be greatly appreciated.
Red
You need to request access for Google Carddav API, i.e. https://www.googleapis.com/auth/carddav
I fear that still might not be enough rights, because even with that permission (and also the permission for https://www.googleapis.com/auth/contacts) I get empty reports for my addressbook. That's very strange. Even after putting a contact with my client.
I have been playing around with this today and succeeded just now.
I am using two oauth scopes
https://www.googleapis.com/auth/carddav
https://www.google.com/m8/feeds
I was getting a 403 when just using the second one.
I then do a depth 1 propfind on getetag and then a multiget to get the vcards.
The response is super speedy.
p.s. With the URL you are using you will also get an http-redirect
According to this:
http://msdn.microsoft.com/en-us/library/dd633705(v=exchg.80).aspx
In each EWS response, the version of Exchange that generated the response is indicated by the ServerVersionInfo element. The following example shows a ServerVersionInfo element that represents a response from Exchange 2010 SP1.
The example on that page has:
Version="Exchange2010_SP1"
I'm currently working with an Exchange Online account, and the value I'm seeing in EWS server responses is:
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo [xmlns' snipped]
MajorVersion="15" MinorVersion="0" MajorBuildNumber="800" MinorBuildNumber="16"
Version="V2_6"/>
</s:Header>
So it's Version="V2_6", which I can't find in the EWS reference.
1 - Is this to be expected for Exchange Online? What about Office 365 accounts?
2 - Where does V2_6 fit into the sequence of: Exchange2007, Exchange2007_SP1, Exchange2010, .... Exchange2013?
In other words, when I see Version="V2_6" in server responses, what schema version can I use in my requests' <RequestServerVersion>?
I had the same issue with a V2_22 version number being returned.
Quoting from answers to my question at the Exchange Server development forum:
"Exchange for Office 365 [ed: Exchange Online] has its own life (custom build) so it does not follow the Exchange 2013 version except for the major version."
You can use the Exchange2013 RequestServerVersion when doing requests to the Office 365 EWS API. If you don't want to do that:
FreeRangeEggs suggest in his answer (here) to rely on MajorVersion, but the answer from Glen Scales (there) says to use AutoDiscovery to detect what schemas are supported.
It looks like Version="Exchange2010_SP1" is only for sending the requests, and not part of the response.
<soap:Header>
<t:RequestServerVersion Version="Exchange2013" />
</soap:Header>
The request version does not match the response version, and is wrapped in different tags.
<h:ServerVersionInfo MajorVersion="15"
MinorVersion="0"
MajorBuildNumber="785"
MinorBuildNumber="6"
Version="V2_6"
xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
I was going to suggest you use the MajorVersion, but that has only been available from 2010 up.
I'm attempting to access MS CRM that's exposed via IFD, and I'm having authentication issues.
The SOAP endpoint is behind NTLM, which I've been able to access. The problem is, I'm getting 401 responses when passing requests like the following:
<?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">
<soap:Body>
<Execute xmlns="http://schemas.microsoft.com/crm/2007/CrmDiscoveryService">
<Request xsi:type="RetrieveCrmTicketRequest">
<OrganizationName>#{CRM_CONFIG[:org_name]}</OrganizationName>
<UserId>#{CRM_CONFIG[:username]}</UserId>
<Password>#{CRM_CONFIG[:password]}</Password>
</Request>
</Execute>
</soap:Body>
</soap:Envelope>
Is there any way of debugging this on the server? Any logs I can check to get a more meaningful error message?
I'm also getting a 401 when attempting the following request (this time to the CrmService.asmx endpoint):
<?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\">
<soap:Header>
<CrmAuthenticationToken xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">
<AuthenticationType xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">2</AuthenticationType>
<OrganizationName xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">#{CRM_CONFIG[:org_name]}</OrganizationName>
<CallerId xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">#{TOUCH}</CallerId>
</CrmAuthenticationToken>
</soap:Header>
<soap:Body>
<RetrieveMultiple xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">
<query xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:QueryExpression\">
<q1:EntityName>contact</q1:EntityName>
</query>
</RetrieveMultiple>
</soap:Body>
</soap:Envelope>
Ok, the problem was a misunderstanding of the setup:
When using NTLM, Active Directory authentication is used, meaning that the CrmAuthenticationToken should have looked like this:
<CrmAuthenticationToken xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">
<AuthenticationType xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">0</AuthenticationType>
<OrganizationName xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">#{CRM_CONFIG[:org_name]}</OrganizationName>
</CrmAuthenticationToken>
Note that the CallerId element isn't needed.
You can turn on server side tracing by hand or with a tool. Look for trace files in C:\Program Files\Microsoft Dynamics CRM\Trace. For easy trace file viewing I recommend using CRM Trace Log Viewer.
There are lots of articles about how to call Dynamics CRM web services from JavaScript. I can imagine those will come in handy.
In my experience, two more tools will also come handy, Fiddler to trace http requests and responses and SoapUI for web service testing and debugging.
Also note, that Dynamics CRM 2011 will come with REST based services in addition to SOAP based, which will greatly simplify CRM web service usage from non-.net products.