0

I have a PHP webapp that needs to connect to dynamics 365 ax soap services.

I was given a wsdl url and from there i am trying to get the values.

I used to get Forbidden error:608 now i get HTTP code 400 Bad Request

I am authenticating, getting token, and passing it with my POST method

POST /soap/services/ webservice?wsdl HTTP/1.1    
Host: domain.sandbox.ax.dynamics.com    
Accept: text/xml    
Connection:Keep-Alive    
Content-type: text/xml    
Authorization: Bearer tokenString    
Soapaction: "http://tempuri.org/webservice/method"    
Content-Length lengthOfXML

Server Response:

HTTP/1.1 400 Bad Request Cache-Control: private Server:.. Strict-Transport-Security: max-age..; includeSubDomains Set-Cookie:ASP.NET_sessionId=.....;path=/;secure; HttpOnly Set-Cookie: ms-dyn-csrftoken:........ p3p: CP="No P3P policy defined. Read Microsoft privacy ... LinkID=271135" .. 

//my XML that i pass as a curl POSTFIELD
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:i0="http://tempuri.org"  xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" >
<soap:Header>
     <CallContext  xmlns="schemas.microsoft.com/.../datacontracts">
      <Company>some</Company>
       <Language>en-us</Language>
        <MessageId>0</MessageId>
         <PartitionKey>286942</PartitionKey>
     </CallContext>
</soap:Header>

<soap:Body>
   <i0:nameofmethod >
   <parameter>25536</parameter>
   </i0:nameofmethod>
</soap:Body>
</soap:Envelope>

I need to get some kind of value a HTTP 200 OK at least.. I should get an array of strings.

  • Have you tried testing the service with SoapUI as described in [Query the Finance and Operations SOAP custom service by using SoapUI](https://learn.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/data-entities/third-party-service-test#query-the-finance-and-operations-soap-custom-service-by-using-soapui)? Please [edit] your answer into your question. – FH-Inway Aug 01 '19 at 16:52
  • Do not update your original issue with a completely new one. If you managed to resolve your original issue, you can post the answer to your own question and mark it as correct. If you have a new issue you can post it as a new question. – 10p Aug 02 '19 at 10:38

1 Answers1

0

I discovered that my Bad request was coming from adding a string in the header before my XML. In some answers from other forums I was searching they suggested to add "xmlRequest=" string before the XML string itself and I forgot I added that and that was causing a problem. I also removed the first line string with the UTF code

<?xml version="1.0" encoding="utf-8" ?>

And added the soap envelope directly. I used SOAPUI to help make sure the structure is correct.

I am still facing a problem with calling my method though but that actually has a different error

Forbidden 1317 System.ComponentModel.Win32Exception The specified account does not exist

Which I am hoping I can find a fix. with a different POST.