title: How to attach X509Certificate2 to webservice (Apple GSX / C# specific)
body: <p>Apple released their New Generation WSDL on the 15 of August this year (2015) and the big change was that every call to the WSDL had to be validated with a certificate file.</p>
  
  <p>I've done the process to get the certificate from Apple, and I've whitelisted our server IP, and I've even verified that I can get access to the service endpoint from our server by coding a simple interface using HttpWebRequest where I easily can attach the certificate using webRequest.ClientCertificates.Add(), so I know everything is ready for it to work.</p>
  
  <p>But, my problem arises when I download the WSDL from <a href="https://gsxwsut.apple.com/apidocs/prod/html/WSArtifacts.html?user=asp" rel="nofollow noreferrer">https://gsxwsut.apple.com/apidocs/prod/html/WSArtifacts.html?user=asp</a></p>
  
  <p>I import the WSDL into Visual Studio and when I try to make an instance of the client class, the only one I find is GsxWSEmeaAspPortClient, which seems to be correct as it has all the functions for authenticate and various tools, but it does not have ClientCertificates. It does have ClientCredentials which have ClientCertificate, but when I try to set the cert there, it's as tho it's never set.</p>
  
  <p>I'm guessing the service code transmits the data via either HttpWebRequest or WebRequest, so if I just can get to the request code from my instance of the class (GsxWSEmeaAspPortClient) I can probably fix it, but I can't seem to get there.</p>
  
  <p>I've looked at this question: <a href="https://stackoverflow.com/questions/31583062/how-can-i-connect-with-apples-gsx-newgeneration-webservices-with-wcf">How can I connect with Apple&#39;s GSX NewGeneration webservices with WCF?</a> which suggests it really should be that easy, but I don't have the GsxWSEmeaAspService, only the GsxWSEmeaAspPortClient from my Visual Studio's generation of the WSDL.</p>
  
  <p>If anyone has any ideas which can point me in any direction towards victory I'd be eternally grateful.</p>
  
  <p>I'm using Visual Studio 2013 and the solution is .Net v4.5.1 if that makes any difference.</p>