How to retrieve the headers from a SoapFault - php

I'm using PHP's SoapClient to connect to a webservice (which is out of my control). One of the SoapFaults I'm receiving is as follows (formatted for readability):
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Infolog xmlns="Infolog" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<InfologMessage xmlns="http://schemas.datacontract.org/2004/07/Microsoft.Dynamics.AX.Framework.Services">
<InfologMessageType>Error</InfologMessageType>
<Message>Customer 6729 not found.</Message>
</InfologMessage>
</Infolog>
</s:Header>
<s:Body>
<s:Fault>
<faultcode>s:Client</faultcode>
<faultstring xml:lang="en-US">Request Failed. See the Exception Log for details.</faultstring>
<detail xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<AifFault xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/Fault" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<CustomDetailXml i:nil="true" />
<FaultMessageListArray i:nil="true" />
<InfologMessageList xmlns:b="http://schemas.datacontract.org/2004/07/Microsoft.Dynamics.AX.Framework.Services" i:nil="true" />
<StackTrace i:nil="true" />
<XppExceptionType>3</XppExceptionType>
</AifFault>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
When PHP throws the SoapFault exception, the message is the Request Failed. See the Exception Log for details. as would be expected. But what I really need is the Infolog entry from the Header. Is there any way to retrieve the Header params, other than calling __getLastResponse() and parsing the entire XML myself, which seems very clunky?
I am open to switching client libraries if that will do it - I've so far tried with the native PHP SoapClient and Zend\Soap\Client

Related

php SOAP request gives internal server error with specific method

im trying to build a soap request for the following wsdl method= "GetData"
note that not all the values are required, i've been struggling with this for a week, any help would be very appreciated
Host: xxxxxxxxxxxxxxxx
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "xxxxxxxxxxx"
<?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:Body>
<GetData xmlns="xxxxxx">
<key>string</key>
<transferDef>
<Where />
<OrderBy>
<OrderByItems>
<BinaryArithmetic xsi:nil="true" />
<Categorization xsi:nil="true" />
<Function xsi:nil="true" />
<QueryField xsi:nil="true" />
<QueryForm xsi:nil="true" />
</OrderByItems>
</OrderBy>
<ProjectId>string</ProjectId>
<DbType>Production or Test</DbType>
</transferDef>
<token>
<Id>guid</Id>
<LastResponseIdReturned>long</LastResponseIdReturned>
<FirstResponseIdReturned>long</FirstResponseIdReturned>
<NumberOfResponsesReturned>long</NumberOfResponsesReturned>
<DatasetsReturned>long</DatasetsReturned>
<LastDataSet>boolean</LastDataSet>
<ProjectId>string</ProjectId>
<ChangeTrackingVersion>long</ChangeTrackingVersion>
</token>
</GetData>
</soap:Body>
</soap:Envelope>
Nowadays, the best way to consume SOAP WS in PHP is to use a WSDL to PHP such as the PackageGenerator project which will generate the classes to construct the request, then to send the request then to handle the response all that using PHP objects. The generated classes are sufficiently intuitive to construct the request. In addition, it uses composer as the autoloader.
kind of resolved the issue, the problem was with the <token></token> part.
Since it needs a value of type:guid <Id>guid</Id> that as mentioned in the wsdl and xml request, is a dataset created by a .Net library, and it's used to iterate over the samples, it's quite a complicated request, since it needs previous steps to be fulfilled, so i did the request, by omitting the <token> section

USI Webservice SOAP Format

I am in the process of developing process to communicate with the Unique Student Identifier (USI) Webservice. I have a Vanguard token, courtesy of some nice (SoapClient avoiding) code by Sergey Vidusov (thanks!) and I'm trying to use the contents of that token in my (also SoapClient avoiding) SOAP request to the USI service. I am using the "example security header" from the V2.0 Technical Services contract (P79) as a template and trying to fill in the blanks from the token and despite a few dozen slightly varied iterations, I constantly get:
An error occurred when verifying security for the message.
in the SOAP fault section of the response. I won't be surprised to learn that I am going about this the wrong way, but I am, for the moment out of ideas.
From the token, I am taking the Binary Secret and using it as the Signature value and the SecurityTokenReference->KeyIdentifier as the KeyIdentifier in my request. I've also copied the entire EncryptedAssertion section from the token in to the request.
My (supposedly valid) XML is like
<s:Envelope
xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:a="http://www.w3.org/2005/08/addressing"
xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<a:Action s:mustUnderstand="1">http://usi.gov.au/ws/2015/VerifyUSI</a:Action>
<a:MessageID>urn:uuid-594a3e4f2c463</a:MessageID>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1"> http://usi.gov.au/ws/2015/VerifyUSI </a:To>
<o:Security s:mustUnderstand="1"
xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<u:Timestamp u:Id="_0">
<u:Created>2017-06-21T09:37:19.000Z</u:Created>
<u:Expires>2017-06-21T10:37:19.000Z</u:Expires>
</u:Timestamp>
<EncryptedAssertion
xmlns="urn:oasinametc:SAML:2.0:assertion">
<EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" xmlnxenc="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"/>
<KeyInfo
xmlns="http://www.w3.org/2000/09/xmldsig#">
<EncryptedKey xmlne="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p">
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
</EncryptionMethod>
<KeyInfo>
<SecurityTokenReference xmlno="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<X509Data>
<X509IssuerSerial>
<X509IssuerName>CN=Australian Government Notary Services OCA, OU=For Development purposes ONLY, OU=Australian Authentication and Notary Services, O=Australian Government, C=AU</X509IssuerName>
<X509SerialNumber>137894267415199651126496945754681728351</X509SerialNumber>
</X509IssuerSerial>
</X509Data>
</SecurityTokenReference>
</KeyInfo>
<CipherData>
<CipherValue>Bc30iHzG4b9ypeC0q8+wvCRox6jTplCg4hKMUpNAXhmhzQyCfFgb3ROihGMB6wLb1moTT/+WpxsMljpeBTKu3oYo8anxwQQf6921Sz7lJCGUrWWMg9IZxq9qEfE85DBqo7tuhs7qkpHlgsUEC/D3IMRycze7x2wJphs6AFBtNDZwVogrQNyp76AUVCGqMSy7EA5woNOuPZqYYHWUDU7/Lv9Jzp6ccOwYXpmnwsW7dMecN6sJbZeopCNf9FuVHS0OJi/l7uadi3VDwRJuiPEB09tETvYNZpUDf/BFQPnHyuWfrjj4nRUKEQx9KcE092+z23n2M8PQmuuEAyRAOnWGNg==</CipherValue>
</CipherData>
</EncryptedKey>
</KeyInfo>
<CipherData>
<CipherValue>7tlxrWKyVSkOPHjiuFWcCsF7Ekzz+bBS47vjQlztc5pi9QTqrU2x/NQQcc19jglPkf+Hf++bGMZ0Q01vtPriSdK9nYWO/sUZSLscHa+1cnPDG4G80Aq5M27eJES4199VCWnoUtEwiXAeNSBHToEM3cxd+IW4BPNWF2DfiE65EsbtVMrdMWtBxgtGCxQexzxZ8pw6aEekvOkKV6WiQywUCc33Md9tadnGKYLinzIQzqq9LWx/D4YDJtq2SoQS5idJHZSknEkOYIRDcKTqu0zfUYYWcO1fV4nElGQkvHrbyo//8Qf8jBeEumGT1YbBjyn3J6cxGAF6iXhQNO/UzrBzqH0WQdV0W2BefbfTI5icbIwLBNbNmYpgJAd07MKnFOH3k/Hamh3nC0naK1ybXtyWuk7a3RxT8gufiW4aPpm7xQMzJisvd4QsbJ/BpstN6NJk0pvBuD85LQTT3OKVf0q9Ll3sZxA5lLHj6z2pRCefMLeEzvr1OXA8aZKOR0cvsm9ROobhNkUMVpFZqSq5tv0AfutUJESZh1P9dqABaZ85u+IvOj35nK83klUkzPZCAda/7zaA8TVdUhcSwcfigNvSf1kOy+Nr1++4OnkU+/8ZEbtYih6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tvpKSMp2oclIH0nwKyZheBOu9dPTu8oCC/CyXYrFO5ivln/W/m976ffnSuXk/+D4VF63Xy/UD4+eisrRfG+pWcZV5rFHNrRtaZaHP4SOQlJdB02h0T5oe+QDSfKEFpG5haI7TrUgtxWqMp3FzGj44FuhLCqQosEXwHa54tbT2eKjnFY2efhE055N12S2ELAxntCQ52USi8auzMACBKY6vzbr3PNa29GiCIXaEAGojrm+UAj8XreMORA5+Nqj5iPkhhVrWXseVmgMRg2oNcNYUcnCVbICuyQSCVbheqmFFBssotxgCCR6jf+G6VFLDGGWRKdwKsclgUs3Nk0CADDWI5Xyb31hoFPadAAbssS6Klxdsr3a5RSOJWjWeqjkOD11AGMfRyYBcL5LOPqxDbVBAoL162k9j5rYFqvW6DzgGLgHBGfXEnzZnTo5dm6dk/kSNma4paXiuD1zhEhWLXM20p4lR3CQCHR6vC2RxJOAYc4OThiEDPvxQ6OJDwIsLuM0IFAJZ3nji0vo2wBm6jFep2VX3x8CatC8LA2H5Y9nw+vkO810e+FTggU+8xLfNTawdtin/KwhA0hnWaARCRyEvPUnNdPCUyP+PGa5cIOGz+z8xjZkbDVsjr41Z6Tkf0tufMgsWYoYfd166JhKbkJo+70G0JIO5Ieb5kca1GGubULG/RjnB7TN8XM8xoIBA4KkiqPbVC7KyIjJw8hSks8SdYGhfm3iEidqYXx51LyB1ukItSOe/H+8agpkpNG9s7b+CJrZOwqQoqFW7Pxz4YJEcTBQH1/rGEZDjeUcyHC8BoiSnfoBGFKggBh1MWpz63td4TnGc8bQ9sMpFMBMUD0gWOhhV4QWlhTsJr4PR7Rh4to1zR+Wq1ydobj4u36Vu+Vo96Tm15JzW9TWzLaotVx/Lc6VkfIx8DqCPToq4m3GDdMNO9QN2rI</CipherValue>
</CipherData>
</EncryptedData>
</EncryptedAssertion>
<Signature
xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></CanonicalizationMethod>
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#hmac-sha1"></SignatureMethod>
<Reference URI="#_0">
<Transforms>
<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></Transform>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod>
<DigestValue>3d5GbpTJJ2uX3t4fJz3oT3TuaUA=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>3zexIO6yp7PTD1M7H7BD3rURd2Yj35ELKRSSuLqVHso=</SignatureValue>
<KeyInfo>
<o:SecurityTokenReference k:TokenType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1"
xmlns:k="http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd">
<o:KeyIdentifier ValueType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID">_ef36244c-da95-47ed-9abf-ddce3c85edd1</o:KeyIdentifier>
</o:SecurityTokenReference>
</KeyInfo>
</Signature>
</o:Security>
</s:Header>
<s:Body>
<soap:Body
xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<u:VerifyUSI
xmlns:u="http://usi.gov.au/2015/ws">
<u:OrgCode>970003</u:OrgCode>
<u:USI>ABCDEFGHJK</u:USI>
<u:FirstName>John</u:FirstName>
<u:FamilyName>Smith</u:FamilyName>
<u:DateOfBirth>1971-12-01</u:DateOfBirth>
</u:VerifyUSI>
</soap:Body>
</s:Body>
I feel I am close ... but just need another clue to propel me forward
I just ran your XML through an online XML validator at http://www.xmlvalidation.com, and it says XML document structures must start and end within the same entity.. Looking at your XML (and this might just be a screwed copy paste to SO), it appears you don't have a closing tag for </s:Envelope>.
Add that first if it isn't there. If it is, you'll need to look in your PHP error_log and get the real error message and stack trace so you can debug a little further.

Convert xml request to array in php SoapClient

I have following xml file that I have to send as request to a Soap service from a SoapClient in php. I used the SoapVar to create array to sending request but the respond node is not present there. Anyone please , can you help me to convert this xml to array to make request to consume the Soap service
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns4:Send xmlns:ns4="hidden" xmlns="Envelope" xmlns:ns2="hidden" xmlns:ns3="hidden">
<ns4:Pack>
<Envelope>
<Header>
<ID>string</ID>
<StringFirst>string</ns2:StringFirst>
</Header>
<Payload xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns3:SmsMessage">
<ns3:fieldOne>true</ns3:DeliveryReports>
<ns3:fieldTwo xsi:type="ns3:hidden">
<ns3:fieldThree></ns3:ApplicationNumber>
</ns3:fieldTwo>
<ns3:SomeFiled xsi:type="ns3:hidden">
<ns3:number>123</ns3:number>
</ns3:SomeField>
<ns3:Content xsi:type="ns3:hidden">
<ns3:Text>String</ns3:Text>
</ns3:Content>
</Payload>
</Envelope>
</ns4:Pack>
</ns4:Send>
</S:Body>
</S:Envelope>
Thank you 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>

php consume WCF SSL SOAP Client 1.2

Im having some problems consuming a wsHttpBinding WCF from PHP. I originally tried to use SOAP1.2 but couldnt get it to specify the WS Action.
I downloaded the nusoap library. I was originally getting an error saying that the webservice wouldnt accept the data due to a type mismatch (text/xml instead of the expected application/soap+xml). I managed to make changes to nusoap.php to send the data as application/soap+xml). Now that doesnt throw an error, i get 400 bad request error from the server.
I can consume the service from WCFTestClient and also from SOAPUI without any messing around, but just cannot get it to fly from PHP. I even copied the entire soap envelope from SOAPUI and set the $soapmsg in nusoap.php to be exactly that and it still fails.
So anyone want to offer some guidance.
EDIT
This is the code i was trying in SOAP 1.2
$params = array("soap_version"=> SOAP_1_2,
"trace"=>1,
"exceptions"=>0,
);
$client = #new SoapClient('https://localhost/wcftest/Service.svc?wsdl',$params);
$retval = $client->GetData(array('value'=>'stuff'));
if (is_soap_fault($retval)) {
trigger_error("SOAP Fault: (faultcode: {$retval->faultcode}, faultstring: {$retval->faultstring})", E_USER_ERROR);
}
EDIT #2
This is the code that works out of SOAPUI
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
<soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:Action>http://tempuri.org/IService/GetData</wsa:Action></soap:Header>
<soap:Body>
<tem:GetData>
<!--Optional:-->
<tem:value>stuff</tem:value>
</tem:GetData>
</soap:Body>
</soap:Envelope>
After adding the SoapHeaders manually as mentioned by Gords link below i get this as the __last_request when debugging with netbeans and still the same error
"<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://tempuri.org/">
<env:Header>
<ns1:Action>http://tempuri.org/IService/GetData</ns1:Action>
</env:Header>
<env:Body><ns1:GetData><ns1:value>stuff</ns1:value></ns1:GetData></env:Body></env:Envelope>
any advice??
Thanks!
Andy
Ok so i got this to work. Thanks to Gord for making me double check stuff that i had overlooked earlier on.
I ended ditching nusoap and just sticking with with SOAP 1.2. Here is my php code
//Declare some paramaters for our soapclient. Need to make sure its set to soap 1.2
$params = array("soap_version"=> SOAP_1_2,
"trace"=>1,
"exceptions"=>0,
);
//Create the soap client
$client = new SoapClient('https://localhost/wcftest/Service.svc?wsdl',$params);
//add some WSAddressing Headers in. Ensure that you have the Namespace as the address if you are using wsHttpBinding on the endpoint
//This was the step that took me the longest to figure out!
$actionHeader = new SoapHeader('http://www.w3.org/2005/08/addressing','Action','http://tempuri.org/IService/GetData',true);
//Add the headers into the client
$client->__setSoapHeaders($actionHeader);
//Make the call and pass in the variables that we require to go to the server
$retval = $client->__soapCall('GetData',array('value'=>'stuff'));
//Some Error Catching
if (is_soap_fault($retval)) {
trigger_error("SOAP Fault: (faultcode: {$retval->faultcode}, faultstring: {$retval->faultstring})", E_USER_ERROR);
}
and the working envelope
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://tempuri.org/" xmlns:ns2="http://www.w3.org/2005/08/addressing">
<env:Header>
<ns2:Action env:mustUnderstand="true">http://tempuri.org/IService/GetData</ns2:Action>
</env:Header>
<env:Body>
<ns1:GetData/>
</env:Body>
</env:Envelope>
and the web.config file from the WCF Service
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<connectionStrings>
<add name="Timeforce" connectionString="Data Source=apps.ziptrek.com;Initial Catalog=qqest;User ID=qqest; Password=qqest;"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="TransportSecurity">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="Service" behaviorConfiguration="Service1">
<endpoint address="https://localhost/wcftest/Service.svc" binding="wsHttpBinding" bindingConfiguration="TransportSecurity" contract="IService"></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Service1">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="httpsService1">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>

Categories