CardDAV get all contacts from iCloud - php

I try to get all contacts from an iCloud Account...
First I run:
<?xml version="1.0" encoding="UTF-8"?>
<d:propfind xmlns:d="DAV:">
<d:prop>
<d:current-user-principal/>
</d:prop>
</d:propfind>
Then I get /xxxxxxxxxxx/carddavhome/ and run:
<?xml version="1.0" encoding="UTF-8"?>
<d:propfind xmlns:d="DAV:" xmlns:card="urn:ietf:params:xml:ns:carddav">
<d:prop>
<card:addressbook-home-set/>
</d:prop>
</d:propfind>
This give me the URL https://pXX-contacts.icloud.com:443/xxxxxxxxxxx/carddavhome/ then I send the following request to this URL:
<?xml version="1.0" encoding="UTF-8"?>
<d:propfind xmlns:d="DAV:" xmlns:card="urn:ietf:params:xml:ns:carddav">
<d:prop>
<d:displayname/>
<d:resourcetype/>
</d:prop>
</d:propfind>
And I get:
<?xml version="1.0" encoding="UTF-8"?>
<multistatus xmlns="DAV:">
<response>
<href>/xxxxxxxxxxx/carddavhome/</href>
<propstat>
<prop>
<resourcetype>
<collection/>
</resourcetype>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
<propstat>
<prop>
<displayname/>
</prop>
<status>HTTP/1.1 404 Not Found</status>
</propstat>
</response>
</multistatus>
If I try to run this to the the URL https://pXX-contacts.icloud.com:443/xxxxxxxxxxx/carddavhome/contacts
<?xml version="1.0" encoding="UTF-8"?>
<card:addressbook-query xmlns:d="DAV:" xmlns:card="urn:ietf:params:xml:ns:carddav">
<d:prop>
<d:getetag/>
<card:address-data/>
</d:prop>
</card:addressbook-query>
I get: Improperly formed XML encountered, unexpected root node
What is my mistake? The first 2 queries work and give me the expected results, the 3rd one should give me a list of the addressbooks and groups and the 4th one should give me all VCards.

For the first issue, you did not provide the whole HTTP request but I suspect that you are missing a Depth header with a value of 1:
Depth: 1
For the second issue, there does not seem to be anything wrong with your xml payload. Your url on the other hand seems incorrect as it is at least missing the ending slash that denotes a collection (some *DAV servers are more strict about it). Hopefully, solving the first issue will allow you to use the right url when doing the address-book query.

Related

How to make proper SOAP request using PHP SoapClient when we see an example

I want to receive data using method GetCruise
How to do that in php using SoapClient, of course i know all URLs and I've got PartnerName, Password and AgencyCode
especially i need to know how to construct proper header of envelope using SoapClient::__setSoapHeaders
GetCruise
Call:
Proxy.Availability.GetCruise(“FO11060119”);
Parameters:
CruiseCode - the cruise code to be returned
Returns:
a fully described cruise (including itinerary and segments of an itinerary).
Example of soap envelope:
(headers must contain agency data - name paswword etc. i've got it)
SOAPAction: "http://schemas.costacrociere.com/WebAffiliation/GetCruise"
<?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>
<Agency xmlns="http://schemas.costacrociere.com/WebAffiliation">
<Code>1111</Code>
<Culture />
</Agency>
<Partner xmlns="http://schemas.costacrociere.com/WebAffiliation">
<Name>AAAA</Name>
<Password>XXXX</Password>
</Partner></soap:Header>
<soap:Body>
<GetCruise xmlns="http://schemas.costacrociere.com/WebAffiliation">
<CruiseCode>FO11060119</CruiseCode>
</GetCruise>
</soap:Body>
</soap:Envelope>

SOAPServer+php+iis v6 (not correct closing tag)

thanks for reading. I am having a big problem using the SOAPServer class from php.
when we make the test we have this respons, that works well:
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:WSDL" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:NotificacionClienteResponse>
<NotificacionClienteReturn xsi:type="xsd:string"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<NotificacionCliente>
<RESULTADO>
<CODIGORETORNO>8</CODIGORETORNO>
<DESCRIPCIONRETORNO>Xml incorrecto</DESCRIPCIONRETORNO>
</RESULTADO>
</NotificacionCliente>]]>
</NotificacionClienteReturn>
</ns1:NotificacionClienteResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
but when we do the same, but in other server, we have this response:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:WSDL" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:NotificacionClienteResponse>
<NotificacionClienteReturn xsi:type="xsd:string"><?xml version="1.0" encoding="UTF-8"?>
<NotificacionCliente>
<RESULTADO>
<CODIGORETORNO>8</CODIGORETORNO>
<DESCRIPCIONRETORNO>Xml incorrecto</DESCRIPCIONRETORNO>
</RESULTADO>
</NotificacionCliente>
</NotificacionClienteReturn>
</ns1:NotificacionClienteResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope
as you can see in the second respons there are 3 different problems:
it appers &lt and &gt in place of < and >
at the end of the xml its missing de >
and the xml its not formated (i did it for you :) )
Information about the server:
same wsdl, web server, php_soap.dll, php.ini
we use iis v6 and php v5.2.9-2
the php is calling the SOAPServer this way, in both servers:
new SOAPServer($Path, array('encoding'=>'ISO-8859-1'))
well, any information you can tell us or any clue you might think its worth tring just tell it...
of course, the same if you need more information.
thanks you all in advance!

INVALID_TYPE when creating salesforce attachment

Bellow is the XML POST and Response i get from the sales force servers.
Im trying to add an attachment to an Account but i keep getting INVALID_TYPE.
Im using NuSoap instead of the SalesForce PHP library because the server i'm working on doesnt have the SOAP extension required.
I have no issue with going in and amending the library to make it work but i dont have a clue whats wrong with the XML to fix the issue. I get query information perfectly fine.
All help and advice appreciated!
<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header>
<nu2113:SessionHeader xmlns:nu2113="urn:enterprise.soap.sforce.com">
<sessionId>00Di00000{---cutting out for privacy--}UrYmByvpO5yRWIK0Gmy</sessionId>
</nu2113:SessionHeader>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<create xmlns="urn:enterprise.soap.sforce.com">
<sObject>
<type xsi:type="xsd:string">Attachment</type>
<fieldsToNull>
<elementName xsi:type="xsd:string">fieldsToNull</elementName>
<values xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[5]">
<item xsi:type="xsd:string">OwnerId</item>
<item xsi:type="xsd:string">IsPrivate</item>
<item xsi:type="xsd:string">IsPartnerShared</item>
<item xsi:type="xsd:string">ConnectionSentId</item>
<item xsi:type="xsd:string">BodyLength</item>
</values>
</fieldsToNull>
<Id xsi:nil="true"/>
<ParentId xsi:type="xsd:string">001i000000JG17b</ParentId>
<Name xsi:type="xsd:string">Test document</Name>
<Description xsi:type="xsd:string">Test upload from WIN form</Description>
<ContentType xsi:type="xsd:string">.pdf</ContentType>
<Body xsi:type="xsd:string">hello</Body>
</sObject>
</create>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
HTTP/1.1 100 Continue
HTTP/1.1 500 Server Error
Date: Mon, 13 Jan 2014 15:49:56 GMT
Content-Type: text/xml;charset=UTF-8
Content-Length: 676
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="urn:fault.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>sf:INVALID_TYPE</faultcode>
<faultstring>INVALID_TYPE: Must send a concrete entity type.</faultstring>
<detail>
<sf:InvalidSObjectFault xsi:type="sf:InvalidSObjectFault">
<sf:exceptionCode>INVALID_TYPE</sf:exceptionCode>
<sf:exceptionMessage>Must send a concrete entity type.</sf:exceptionMessage>
<sf:row>-1</sf:row>
<sf:column>-1</sf:column>
</sf:InvalidSObjectFault>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
This line might be the problem:
<ContentType xsi:type="xsd:string">.pdf</ContentType>
that is not a valid content type. try this:
<ContentType xsi:type="xsd:string">application/pdf</ContentType>

FedEx XML Api Tracking Request Issues

I'm attempting to implement FedEx Package Tracking in a project using the XML api. The following is my tracking request:
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v6="http://fedex.com/ws/track/v6">
<soapenv '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v6="http://fedex.com/ws/track/v6">
<soapenv:Header/>
<soapenv:Body>
<v6:TrackRequest>
<v6:WebAuthenticationDetail>
<v6:UserCredential>
<v6:Key>'.fedex_accesskey.'</v6:Key>
<v6:Password>'.fedex_password.'</v6:Password>
</v6:UserCredential>
</v6:WebAuthenticationDetail>
<v6:ClientDetail>
<v6:AccountNumber>'.fedex_account.'</v6:AccountNumber>
<v6:MeterNumber>'.fedex_meter.'</v6:MeterNumber>
<v6:IntegratorId></v6:IntegratorId>
<v6:Localization>
<v6:LanguageCode>EN</v6:LanguageCode>
<v6:LocaleCode>US</v6:LocaleCode>
</v6:Localization>
</v6:ClientDetail>
<v6:TransactionDetail>
<v6:CustomerTransactionId>Track By Number</v6:CustomerTransactionId>
<v6:Localization>
<v6:LanguageCode>EN</v6:LanguageCode>
<v6:LocaleCode>US</v6:LocaleCode>
</v6:Localization>
</v6:TransactionDetail>
<v6:Version>
<v6:ServiceId>trck</v6:ServiceId>
<v6:Major>6</v6:Major>
<v6:Intermediate>0</v6:Intermediate>
<v6:Minor>0</v6:Minor>
</v6:Version>
<v6:PackageIdentifier>
<v6:Value>'.$tracking_number.'</v6:Value>
<v6:Type>TRACKING_NUMBER_OR_DOORTAG</v6:Type>
</v6:PackageIdentifier>
</v6:TrackRequest>
</soapenv:Body>
</soapenv:Envelope>';:Header/>
<soapenv:Body>
<v6:TrackRequest>
<v6:WebAuthenticationDetail>
<v6:UserCredential>
<v6:Key>'.fedex_accesskey.'</v6:Key>
<v6:Password>'.fedex_password.'</v6:Password>
</v6:UserCredential>
</v6:WebAuthenticationDetail>
<v6:ClientDetail>
<v6:AccountNumber>'.fedex_account.'</v6:AccountNumber>
<v6:MeterNumber>'.fedex_meter.'</v6:MeterNumber>
<v6:IntegratorId></v6:IntegratorId>
<v6:Localization>
<v6:LanguageCode>EN</v6:LanguageCode>
<v6:LocaleCode>US</v6:LocaleCode>
</v6:Localization>
</v6:ClientDetail>
<v6:TransactionDetail>
<v6:CustomerTransactionId>Track By Number</v6:CustomerTransactionId>
<v6:Localization>
<v6:LanguageCode>EN</v6:LanguageCode>
<v6:LocaleCode>US</v6:LocaleCode>
</v6:Localization>
</v6:TransactionDetail>
<v6:Version>
<v6:ServiceId>trck</v6:ServiceId>
<v6:Major>6</v6:Major>
<v6:Intermediate>0</v6:Intermediate>
<v6:Minor>0</v6:Minor>
</v6:Version>
<v6:PackageIdentifier>
<v6:Value>'.$tracking_number.'</v6:Value>
<v6:Type>TRACKING_NUMBER_OR_DOORTAG</v6:Type>
</v6:PackageIdentifier>
</v6:TrackRequest>
</soapenv:Body>
</soapenv:Envelope>';
All values are being swapped in correctly, and I am getting a success response back from FedEx. The issue is the response only has one tracking event. The event appears to be the last tracking update from FedEx (in this case, delivery time, date, and address) but is not showing any tracking events along the way.
Here is the response I get: Pastebin
As you can see, the package status is delivered, and the delivery address is listed in , but the origin and the steps along the way are not. Any suggestions on how to get all the tracking info and not just the most recent step? Help appreciated.
You were missing to set to true the IncludeDetailedScans element. Here is an example of a SOAP Envelope:
<?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>
<TrackRequest xmlns="http://fedex.com/ws/track/v6">
<WebAuthenticationDetail>
<CspCredential>
<Key>CSP_KEY</Key>
<Password>CSP_PASSWORD</Password>
</CspCredential>
<UserCredential>
<Key>DEVELOPER_KEY</Key>
<Password>DEVELOPER_PASSWORD</Password>
</UserCredential>
</WebAuthenticationDetail>
<ClientDetail>
<AccountNumber>ACCOUNT_NUMBER</AccountNumber>
<MeterNumber>METER_NUMBER</MeterNumber>
<ClientProductId>CLIENT_PRODUCT_ID</ClientProductId>
<ClientProductVersion>CLIENT_PRODUCT_VERSION</ClientProductVersion>
</ClientDetail>
<Version>
<ServiceId>trck</ServiceId>
<Major>6</Major>
<Intermediate>0</Intermediate>
<Minor>0</Minor>
</Version>
<PackageIdentifier>
<Value>TRACKING_NUMBER</Value>
<Type>TRACKING_NUMBER_OR_DOORTAG</Type>
</PackageIdentifier>
<IncludeDetailedScans>true</IncludeDetailedScans>
</TrackRequest>
</soap:Body>
</soap:Envelope>
Note that the previous request is only valid if you belong to the FedEx CSP program, if you don't, the code below is the right one for your:
<?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>
<TrackRequest xmlns="http://fedex.com/ws/track/v6">
<WebAuthenticationDetail>
<UserCredential>
<Key>DEVELOPER_KEY</Key>
<Password>DEVELOPER_PASSWORD</Password>
</UserCredential>
</WebAuthenticationDetail>
<ClientDetail>
<AccountNumber>ACCOUNT_NUMBER</AccountNumber>
<MeterNumber>METER_NUMBER</MeterNumber>
</ClientDetail>
<Version>
<ServiceId>trck</ServiceId>
<Major>6</Major>
<Intermediate>0</Intermediate>
<Minor>0</Minor>
</Version>
<PackageIdentifier>
<Value>TRACKING_NUMBER</Value>
<Type>TRACKING_NUMBER_OR_DOORTAG</Type>
</PackageIdentifier>
<IncludeDetailedScans>true</IncludeDetailedScans>
</TrackRequest>
</soap:Body>
</soap:Envelope>
Best!
For Version 8, you need to add the following tag, almost at the very bottom of the XML request, right above the closing "TrackRequest" tag:
<ProcessingOptions>INCLUDE_DETAILED_SCANS</ProcessingOptions>
I've found the solution hidden in the FedEx documentation. It is to supply 1 to get the full history. This value defaults to false and omits all that important tracking information.
I know this question wasn't geared towards .NET but if anyone arrives here (like I did) looking for a .NET specific answer to this question, here it is:
Dim request As New TrackRequest()
Dim options(0) As TrackRequestProcessingOptionType
options(0) = TrackRequestProcessingOptionType.INCLUDE_DETAILED_SCANS
request.ProcessingOptions = options

soap api with betfair

It's my first time using the SOAP API by BetFair I have created one XML file and one file that will call that file. I am not understanding how can I call this and get an output. I have created the XML file below:
<?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>
<login xmlns="http://www.betfair.com/publicapi/v3/BFGlobalService/">
<request>
<locationId xmlns="">0</locationId>
<username xmlns="">usrname</username>
<password xmlns="">password</password>
<productId xmlns="">18</productId>
<vendorSoftwareId xmlns="">0</vendorSoftwareId>
</request>
</login>
</soap:Body>
</soap:Envelope>
Now to call this file I have also created one php file to do this.
BetFair has given this link for the login api: https://api.betfair.com/global/v3/BFGlobalService.wsdl
<?php
$get_data = file_get_contents("http://pixelonsell.com/dev2/betfair/login.xml");
$b = html_entity_decode($get_data);
$data= urlencode($b);
print_r($data);
$client = new SoapClient("https://api.betfair.com/global/v3/BFGlobalService.wsdl");
$result = $client->LoginReq($data);
print_r($result);
?>
I don't know why it's not working; can you help me out with this? Thank you in advance.
I would avoid using a dedicated SOAP library; in my experience they often don't work because of inconsistencies in the ways different servers implement the SOAP specification. Use a simple HTTP/HTTPS library instead, with the following headers
SOAPAction: urn:login
Content-Length: #{myContentLength}
Content-Type: text/xml
User-Agent: #{myUserAgent}
and the following payload (assuming you're using the Free API):
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<m:login xmlns:m="https://api.betfair.com/global/v3/BFGlobalService">
<m:request>
<username>#{myUsername}</username>
<password>#{myPassword}</password>
<locationId>0</locationId>
<vendorSoftwareId>0</vendorSoftwareId>
<productId>82</productId>
</m:request>
</m:login>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
It looks to me like you're using the wrong namespace for the login element; should be 'https://api.betfair.com/..' not 'http://www.betfair.com/..'.
Good luck.

Categories