Compamyhouse xml gatway service

Hi ,

I am a web developer using php and myadmin.
I am creating a web site to register a company by using compamyhouse xml gatway service.

My problem is that i don’t know how to sumbit user detail to companyhouse so we can get the response back .

I am trying this but did not get any response plz help

This is my code
<?php
$xml = <<<EOF
<GovTalkMessage xsi:schemaLocation=“http://www.govtalk.gov.uk/schemas/govtalk/govtalkheader http://xmlgw.companieshouse.gov.uk/v1-0/schema/Egov_ch.xsd” xmlns=“http://www.govtalk.gov.uk/schemas/govtalk/govtalkheader” xmlns:dsig=“http://www.w3.org/2000/09/xmldsig#” xmlns:gt=“http://www.govtalk.gov.uk/schemas/govtalk/core” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” >
<EnvelopeVersion>1.0</EnvelopeVersion>
<Header>
<MessageDetails>
<Class></Class>
<Qualifier>error</Qualifier>
<TransactionID></TransactionID>
<GatewayTimestamp>2012-01-23T17:52:11-00:00</GatewayTimestamp>
</MessageDetails>
<SenderDetails>
<IDAuthentication>
<SenderID></SenderID>
<Authentication>
<Method>CHMD5</Method>
<Value></Value>
</Authentication>
</IDAuthentication>
</SenderDetails>
</Header>
<GovTalkDetails>
<Keys/>
<GovTalkErrors>
<Error>
<RaisedBy>CH_XML_Gateway</RaisedBy>
<Number>9999</Number>
<Type>fatal</Type>
<Text>No request XML</Text>
<Location></Location>
</Error>
</GovTalkErrors>
</GovTalkDetails>
<Body><FormSubmission xmlns=“http://xmlgw.companieshouse.gov.uk/Header” xmlns:bs=“http://xmlgw.companieshouse.gov.uk” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=“http://xmlgw.companieshouse.gov.uk/Header http://xmlgw.companieshouse.gov.uk/v2-1/schema/forms/FormSubmission-v2-5.xsd”>
<FormHeader>
<CompanyName>BETA TEST 1 LLP</CompanyName>
<PackageReference>1828</PackageReference>
<FormIdentifier>CompanyIncorporation</FormIdentifier>
<SubmissionNumber>LLP111</SubmissionNumber>
</FormHeader>
<DateSigned>2010-07-20</DateSigned>
<Form>
<CompanyIncorporation xmlns=“http://xmlgw.companieshouse.gov.uk” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=“http://xmlgw.companieshouse.gov.uk http://xmlgw.companieshouse.gov.uk/v2-1/schema/forms/CompanyIncorporation-v2-6.xsd”>
<CompanyType>LLP</CompanyType>
<CountryOfIncorporation>EW</CountryOfIncorporation>
<RegisteredOfficeAddress>
<Premise>1</Premise>
<Street>LEYSHON POOLE STREET</Street>
<PostTown>PONTYPRIDD</PostTown>
<Country>GB-WLS</Country>
<Postcode>CF37 1ND</Postcode>
</RegisteredOfficeAddress>

		    &lt;Appointment&gt;
			&lt;Authentication&gt;
				&lt;PersonalAttribute&gt;BIRTOWN&lt;/PersonalAttribute&gt;
				&lt;PersonalData&gt;HAV&lt;/PersonalData&gt;
			&lt;/Authentication&gt;
			&lt;Authentication&gt;
				&lt;PersonalAttribute&gt;DAD&lt;/PersonalAttribute&gt;
				&lt;PersonalData&gt;FRE&lt;/PersonalData&gt;
			&lt;/Authentication&gt;
			&lt;Authentication&gt;
				&lt;PersonalAttribute&gt;EYE&lt;/PersonalAttribute&gt;
				&lt;PersonalData&gt;BLU&lt;/PersonalData&gt;
			&lt;/Authentication&gt;
			&lt;Member&gt;
			&lt;DesignatedInd&gt;true&lt;/DesignatedInd&gt;
				&lt;Corporate&gt;
					&lt;Forename&gt;WILLIAM&lt;/Forename&gt;
					&lt;Surname&gt;DAVIES&lt;/Surname&gt;
					&lt;CorporateName&gt;TEST NAME&lt;/CorporateName&gt;
					&lt;Address&gt;
						&lt;Premise&gt;6&lt;/Premise&gt;
						&lt;Street&gt;WOOD VIEW&lt;/Street&gt;
						&lt;PostTown&gt;CHURCH VILLAGE&lt;/PostTown&gt;
						&lt;Country&gt;GB-WLS&lt;/Country&gt;
						&lt;Postcode&gt;CF21 1RW&lt;/Postcode&gt;
					&lt;/Address&gt;
					&lt;CompanyIdentification&gt;
					&lt;NonEEA&gt;
							&lt;LawGoverned&gt;AUSTRIAN&lt;/LawGoverned&gt;
							&lt;LegalForm&gt;TEST&lt;/LegalForm&gt;
					&lt;/NonEEA&gt;
					&lt;/CompanyIdentification&gt;
				&lt;/Corporate&gt;
			&lt;/Member&gt;
		&lt;/Appointment&gt;
		
		    &lt;Appointment&gt;
			&lt;Authentication&gt;
				&lt;PersonalAttribute&gt;BIRTOWN&lt;/PersonalAttribute&gt;
				&lt;PersonalData&gt;HAV&lt;/PersonalData&gt;
			&lt;/Authentication&gt;
			&lt;Authentication&gt;
				&lt;PersonalAttribute&gt;DAD&lt;/PersonalAttribute&gt;
				&lt;PersonalData&gt;FRE&lt;/PersonalData&gt;
			&lt;/Authentication&gt;
			&lt;Authentication&gt;
				&lt;PersonalAttribute&gt;EYE&lt;/PersonalAttribute&gt;
				&lt;PersonalData&gt;BLU&lt;/PersonalData&gt;
			&lt;/Authentication&gt;
			&lt;Member&gt;
			&lt;DesignatedInd&gt;false&lt;/DesignatedInd&gt;
				&lt;Person&gt;
					&lt;Title&gt;Mr&lt;/Title&gt;
					&lt;Forename&gt;LEIGH ERIC&lt;/Forename&gt;
					&lt;Surname&gt;DAVIES&lt;/Surname&gt;
					&lt;ServiceAddress&gt;
					&lt;Address&gt;
						&lt;Premise&gt;1&lt;/Premise&gt;
						&lt;Street&gt;LEYSHON POOLE STREET&lt;/Street&gt;
						&lt;PostTown&gt;PONTYPRIDD&lt;/PostTown&gt;
						&lt;Country&gt;GB-WLS&lt;/Country&gt;
					&lt;/Address&gt;
					&lt;/ServiceAddress&gt;
					&lt;DOB&gt;1975-02-01&lt;/DOB&gt;
					&lt;CountryOfResidence&gt;United Kingdom&lt;/CountryOfResidence&gt;
					&lt;PreviousNames&gt;
						&lt;Surname&gt;HUGHES&lt;/Surname&gt;
					&lt;/PreviousNames&gt;
					&lt;ResidentialAddress&gt;
						&lt;SameAsServiceAddress&gt;true&lt;/SameAsServiceAddress&gt;
					&lt;/ResidentialAddress&gt;
				&lt;/Person&gt;
				&lt;/Member&gt;
			&lt;/Appointment&gt;
		
		    &lt;Appointment&gt;
			&lt;Authentication&gt;
				&lt;PersonalAttribute&gt;BIRTOWN&lt;/PersonalAttribute&gt;
				&lt;PersonalData&gt;SWA&lt;/PersonalData&gt;
			&lt;/Authentication&gt;
			&lt;Authentication&gt;
				&lt;PersonalAttribute&gt;DAD&lt;/PersonalAttribute&gt;
				&lt;PersonalData&gt;BIL&lt;/PersonalData&gt;
			&lt;/Authentication&gt;
			&lt;Authentication&gt;
				&lt;PersonalAttribute&gt;EYE&lt;/PersonalAttribute&gt;
				&lt;PersonalData&gt;HAZ&lt;/PersonalData&gt;
			&lt;/Authentication&gt;
			&lt;Member&gt;
			&lt;DesignatedInd&gt;true&lt;/DesignatedInd&gt;
				&lt;Corporate&gt;
					&lt;Forename&gt;HARRY&lt;/Forename&gt;
					&lt;Surname&gt;DAVIES&lt;/Surname&gt;
					&lt;CorporateName&gt;TEST CORPORATE&lt;/CorporateName&gt;
					&lt;Address&gt;
						&lt;Premise&gt;6&lt;/Premise&gt;
						&lt;Street&gt;TREETOPS VIEW&lt;/Street&gt;
						&lt;PostTown&gt;CARDIFF&lt;/PostTown&gt;
						&lt;Country&gt;GB-WLS&lt;/Country&gt;
						&lt;Postcode&gt;CF58 1RW&lt;/Postcode&gt;
					&lt;/Address&gt;
					&lt;CompanyIdentification&gt;
					&lt;EEA&gt;
						&lt;PlaceRegistered&gt;ukraine&lt;/PlaceRegistered&gt;
						&lt;RegistrationNumber&gt;568497&lt;/RegistrationNumber&gt;
					&lt;/EEA&gt;
					&lt;/CompanyIdentification&gt;
				&lt;/Corporate&gt;
			&lt;/Member&gt;
		&lt;/Appointment&gt;
		
			&lt;Appointment&gt;
			&lt;Authentication&gt;
				&lt;PersonalAttribute&gt;BIRTOWN&lt;/PersonalAttribute&gt;
				&lt;PersonalData&gt;SWA&lt;/PersonalData&gt;
			&lt;/Authentication&gt;
			&lt;Authentication&gt;
				&lt;PersonalAttribute&gt;DAD&lt;/PersonalAttribute&gt;
				&lt;PersonalData&gt;BIL&lt;/PersonalData&gt;
			&lt;/Authentication&gt;
			&lt;Authentication&gt;
				&lt;PersonalAttribute&gt;EYE&lt;/PersonalAttribute&gt;
				&lt;PersonalData&gt;HAZ&lt;/PersonalData&gt;
			&lt;/Authentication&gt;
			&lt;Member&gt;
			&lt;DesignatedInd&gt;false&lt;/DesignatedInd&gt;
				&lt;Person&gt;
					&lt;Title&gt;Mr&lt;/Title&gt;
					&lt;Forename&gt;Peter&lt;/Forename&gt;
					&lt;OtherForenames&gt;DAVID ELLIS&lt;/OtherForenames&gt;
					&lt;Surname&gt;Evans&lt;/Surname&gt;
					&lt;ServiceAddress&gt;
					&lt;Address&gt;
						&lt;Premise&gt;1&lt;/Premise&gt;
						&lt;Street&gt;LEYSHON POOLE STREET&lt;/Street&gt;
						&lt;PostTown&gt;PONTYPRIDD&lt;/PostTown&gt;
						&lt;Country&gt;GB-WLS&lt;/Country&gt;
					&lt;/Address&gt;
					&lt;/ServiceAddress&gt;
					&lt;DOB&gt;1959-09-29&lt;/DOB&gt;
					&lt;CountryOfResidence&gt;UNITED KINGDOM&lt;/CountryOfResidence&gt;
					&lt;ResidentialAddress&gt;
						&lt;Address&gt;
							&lt;Premise&gt;17&lt;/Premise&gt;
							&lt;Street&gt;CORDEN DAL&lt;/Street&gt;
							&lt;PostTown&gt;CARDIFF&lt;/PostTown&gt;
							&lt;Country&gt;GB-WLS&lt;/Country&gt;
							&lt;Postcode&gt;CF24 7DH&lt;/Postcode&gt;
						&lt;/Address&gt;
					&lt;/ResidentialAddress&gt;
				&lt;/Person&gt;
			&lt;/Member&gt;
		&lt;/Appointment&gt;
		
		&lt;Appointment&gt;
			&lt;Authentication&gt;
				&lt;PersonalAttribute&gt;BIRTOWN&lt;/PersonalAttribute&gt;
				&lt;PersonalData&gt;SWA&lt;/PersonalData&gt;
			&lt;/Authentication&gt;
			&lt;Authentication&gt;
				&lt;PersonalAttribute&gt;DAD&lt;/PersonalAttribute&gt;
				&lt;PersonalData&gt;BIL&lt;/PersonalData&gt;
			&lt;/Authentication&gt;
			&lt;Authentication&gt;
				&lt;PersonalAttribute&gt;EYE&lt;/PersonalAttribute&gt;
				&lt;PersonalData&gt;HAZ&lt;/PersonalData&gt;
			&lt;/Authentication&gt;
			&lt;Member&gt;
			&lt;DesignatedInd&gt;true&lt;/DesignatedInd&gt;
				&lt;Person&gt;
					&lt;Title&gt;SIR&lt;/Title&gt;
					&lt;Forename&gt;james john david&lt;/Forename&gt;
					&lt;Surname&gt;Evans&lt;/Surname&gt;
					&lt;ServiceAddress&gt;
					&lt;SameAsRegisteredOffice&gt;true&lt;/SameAsRegisteredOffice&gt;
					&lt;/ServiceAddress&gt;
					&lt;DOB&gt;1958-09-29&lt;/DOB&gt;
					&lt;CountryOfResidence&gt;UNITED KINGDOM&lt;/CountryOfResidence&gt;
					&lt;ResidentialAddress&gt;
						&lt;Address&gt;
							&lt;Premise&gt;17&lt;/Premise&gt;
							&lt;Street&gt;CORDEN DAL&lt;/Street&gt;
							&lt;PostTown&gt;CARDIFF&lt;/PostTown&gt;
							&lt;Country&gt;GB-WLS&lt;/Country&gt;
							&lt;Postcode&gt;CF24 7DH&lt;/Postcode&gt;
						&lt;/Address&gt;
					&lt;/ResidentialAddress&gt;
				&lt;/Person&gt;
			&lt;/Member&gt;
		&lt;/Appointment&gt;
		
		&lt;Appointment&gt;
			&lt;Authentication&gt;
				&lt;PersonalAttribute&gt;BIRTOWN&lt;/PersonalAttribute&gt;
				&lt;PersonalData&gt;SWA&lt;/PersonalData&gt;
			&lt;/Authentication&gt;
			&lt;Authentication&gt;
				&lt;PersonalAttribute&gt;DAD&lt;/PersonalAttribute&gt;
				&lt;PersonalData&gt;BIL&lt;/PersonalData&gt;
			&lt;/Authentication&gt;
			&lt;Authentication&gt;
				&lt;PersonalAttribute&gt;EYE&lt;/PersonalAttribute&gt;
				&lt;PersonalData&gt;HAZ&lt;/PersonalData&gt;
			&lt;/Authentication&gt;
			&lt;Member&gt;
			&lt;DesignatedInd&gt;true&lt;/DesignatedInd&gt;
				&lt;Person&gt;
					&lt;Title&gt;Mr&lt;/Title&gt;
					&lt;Forename&gt;JOE&lt;/Forename&gt;
					&lt;Surname&gt;JONES&lt;/Surname&gt;
					&lt;ServiceAddress&gt;
					&lt;SameAsRegisteredOffice&gt;true&lt;/SameAsRegisteredOffice&gt;
					&lt;/ServiceAddress&gt;
					&lt;DOB&gt;1959-09-29&lt;/DOB&gt;
					&lt;CountryOfResidence&gt;UNITED KINGDOM&lt;/CountryOfResidence&gt;
					&lt;ResidentialAddress&gt;
						&lt;Address&gt;
							&lt;Premise&gt;17&lt;/Premise&gt;
							&lt;Street&gt;CORDEN DAL&lt;/Street&gt;
							&lt;PostTown&gt;CARDIFF&lt;/PostTown&gt;
							&lt;Country&gt;GB-WLS&lt;/Country&gt;
							&lt;Postcode&gt;CF24 7DH&lt;/Postcode&gt;
						&lt;/Address&gt;
					&lt;/ResidentialAddress&gt;
				&lt;/Person&gt;
			&lt;/Member&gt;
		&lt;/Appointment&gt;
		
		&lt;Authoriser&gt;
			&lt;Member&gt;
				&lt;Person&gt;
					&lt;Forename&gt;JOE&lt;/Forename&gt;
					&lt;Surname&gt;JONES&lt;/Surname&gt;
				&lt;/Person&gt;
				&lt;Authentication&gt;
					&lt;PersonalAttribute&gt;BIRTOWN&lt;/PersonalAttribute&gt;
					&lt;PersonalData&gt;SWA&lt;/PersonalData&gt;
				&lt;/Authentication&gt;
				&lt;Authentication&gt;
					&lt;PersonalAttribute&gt;DAD&lt;/PersonalAttribute&gt;
					&lt;PersonalData&gt;BIL&lt;/PersonalData&gt;
				&lt;/Authentication&gt;
				&lt;Authentication&gt;
					&lt;PersonalAttribute&gt;EYE&lt;/PersonalAttribute&gt;
					&lt;PersonalData&gt;HAZ&lt;/PersonalData&gt;
				&lt;/Authentication&gt;
			&lt;/Member&gt;				
		&lt;/Authoriser&gt;
		
		&lt;SameDay&gt;false&lt;/SameDay&gt;
	&lt;/CompanyIncorporation&gt;
   &lt;/Form&gt;
&lt;/FormSubmission&gt;

</Body>
</GovTalkMessage>
EOF;
$ch = curl_init(); //initiate the curl session

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // tell curl to return data in a variable
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(“Content-Type: text/xml”));
curl_setopt($ch, CURLOPT_POST, true);

curl_setopt($ch, CURLOPT_TIMEOUT, (int)30); // set timeout in seconds

echo $xmlResponse = curl_exec($ch);
curl_close ($ch);
?>

Does the API have any documentation you can read and/or code examples? As it stands, you’re doing an awful lot wrong I’m afraid.

this is the url where i have to submit my Requested data

https://xmlgw.companieshouse.gov.uk/v1-0/xmlgw/Gateway

This is the example(below) given by company house xml gateway to submit the requested data

http://xmlgw.companieshouse.gov.uk/examples/IN01_v2-6_LLP.xml

will you please check these link and tell me how can i submit my post data

The sample XML you linked to references a XSD, you can view this (rather verbose) document to see what you need to send to the API.

http://xmlgw.companieshouse.gov.uk/v2-1/schema/forms/CompanyIncorporation-v2-6.xsd

You’re going to need something similar to…


<?php
function do_post($data, $uri){
	$curl = curl_init($uri);
	curl_setopt_array($curl, array(
		CURLOPT_SSL_VERIFYHOST	=> false,
		CURLOPT_SSL_VERIFYPEER	=> false,
		CURLOPT_RETURNTRANSFER	=> true,
		CURLOPT_POST						=> true,
		CURLOPT_POSTFIELDS			=> $data,
		CURLOPT_TIMEOUT					=> 10
	));
	return array(
		'response'		=> curl_exec($curl),
		'information'	=> curl_getinfo($curl)
	);
}


var_dump(
	do_post(file_get_contents('example.xml', 'https://xmlgw.companieshouse.gov.uk/v1-0/xmlgw/Gateway'))
);

HI i still did not get success .the code which you suggest to me is also giving the error
Fatal error: Call to undefined function curl_init() in C:\wamp\www\register_company_live\29th_jan\examplexml.php on line 8

Please help

You need to install the curl library/extension, WAMP has a one-click option to enable it.

Yes, you are right. i did not enable the curl.
But after enabling it,i got the following on browser

array(2) { [“response”]=> string(1215) " 1.0
error 2012-02-01T19:11:16-00:00 CHMD5
CH_XML_Gateway 604 fatal Bad Request " [“information”]=> array(20) { [“url”]=> string(54) “https://xmlgw.companieshouse.gov.uk/v1-0/xmlgw/Gateway” [“content_type”]=> string(33) “application/x-www-form-urlencoded” [“http_code”]=> int(200) [“header_size”]=> int(302) [“request_size”]=> int(178) [“filetime”]=> int(-1) [“ssl_verify_result”]=> int(20) [“redirect_count”]=> int(0) [“total_time”]=> float(2.547) [“namelookup_time”]=> float(0.375) [“connect_time”]=> float(0.594) [“pretransfer_time”]=> float(1.422) [“size_upload”]=> float(6753) [“size_download”]=> float(1215) [“speed_download”]=> float(477) [“speed_upload”]=> float(2651) [“download_content_length”]=> float(-1) [“upload_content_length”]=> float(6753) [“starttransfer_time”]=> float(1.656) [“redirect_time”]=> float(0) } }

this(below) is the view source

array(2) {
[“response”]=>
string(1215) "<?xml version=“1.0” encoding=“UTF-8” ?>
<GovTalkMessage xsi:schemaLocation=“http://www.govtalk.gov.uk/schemas/govtalk/govtalkheader http://xmlgw.companieshouse.gov.uk/v1-0/schema/Egov_ch.xsd” xmlns=“http://www.govtalk.gov.uk/schemas/govtalk/govtalkheader” xmlns:dsig=“http://www.w3.org/2000/09/xmldsig#” xmlns:gt=“http://www.govtalk.gov.uk/schemas/govtalk/core” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” >
<EnvelopeVersion>1.0</EnvelopeVersion>
<Header>
<MessageDetails>
<Class></Class>
<Qualifier>error</Qualifier>
<TransactionID></TransactionID>
<GatewayTimestamp>2012-02-01T19:13:42-00:00</GatewayTimestamp>
</MessageDetails>
<SenderDetails>
<IDAuthentication>
<SenderID></SenderID>
<Authentication>
<Method>CHMD5</Method>
<Value></Value>
</Authentication>
</IDAuthentication>
</SenderDetails>
</Header>
<GovTalkDetails>
<Keys/>
<GovTalkErrors>
<Error>
<RaisedBy>CH_XML_Gateway</RaisedBy>
<Number>604</Number>
<Type>fatal</Type>
<Text>Bad Request</Text>
<Location></Location>
</Error>
</GovTalkErrors>
</GovTalkDetails>
<Body>
</Body>
</GovTalkMessage>
"
[“information”]=>
array(20) {
[“url”]=>
string(54) “https://xmlgw.companieshouse.gov.uk/v1-0/xmlgw/Gateway
[“content_type”]=>
string(33) “application/x-www-form-urlencoded”
[“http_code”]=>
int(200)
[“header_size”]=>
int(302)
[“request_size”]=>
int(178)
[“filetime”]=>
int(-1)
[“ssl_verify_result”]=>
int(20)
[“redirect_count”]=>
int(0)
[“total_time”]=>
float(2.422)
[“namelookup_time”]=>
float(0.437)
[“connect_time”]=>
float(0.672)
[“pretransfer_time”]=>
float(1.515)
[“size_upload”]=>
float(6753)
[“size_download”]=>
float(1215)
[“speed_download”]=>
float(501)
[“speed_upload”]=>
float(2788)
[“download_content_length”]=>
float(-1)
[“upload_content_length”]=>
float(6753)
[“starttransfer_time”]=>
float(1.75)
[“redirect_time”]=>
float(0)
}
}