I am setting up a soapserver and for some reason when trying to connect file_get_contents('php://input') is empty.
In Fiddler I can see that the clientprogram is actually sending the following:
<?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><AuthenticationHeader xmlns="http://www.cito.nl/DULTService/"><Username>dult</Username><Password>dult</Password><Brincode>99DE00</Brincode></AuthenticationHeader></soap:Header><soap:Body><DULTValidateCredentials xmlns="http://www.cito.nl/DULTService/" /></soap:Body></soap:Envelope>
The soapclient sends two empty calls first, before sending the one above, not sure if that could be related.
Any help is much appreciated!
Related
I am trying to connect to a SOAP server with PHP in WSDL mode.
In the WSDL file there are defined serveral xmlns in the header.
I am creating a request with the client like this:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="NS1" xmlns:ns2="NS2" xmlns:ns3="NS3">
<env:Body>
<ns3:calculate>
<ns1:something>01</ns1:something>
<ns3:calcnode>
<ns1:beginning>2020-07-01</ns1:beginning>
<ns3:data>
<ns1:Hauptfaelligkeit>01.07</ns1:Hauptfaelligkeit>
<ns3:someothernode>
<ns3:code>AH</ns3:code>
<EL-Sum SumCd="ABC" Sum="20000000"/>
<ns3:something>VB</ns3:something>
<EL-Test TestCd="A" TestVal="9"/>
</ns3:someothernode>
</ns3:data>
</ns3:calcnode>
</ns3:calculate>
</env:Body>
</env:Envelope>
I've modified it a bit because the WSDL is confidental so I cannot provide it.
The problem is with there should be a NS4 but it isn't imported so the SOAP server doesn't get the value.
I found a solution that I can modify the XSD of NS4 and add elementFormDefault=qualified but I cannot do this because I cannot load the locally need to leave them remote.
Can I add the NS manually in the header?
Thanks
I have an issue with a SOAP request I'm sending to an external ASP Web Service. I have used both SoapUI and PHP's SoapClient class, and both times the same issue occurs - an error that tells me The 'http://www.w3.org/2003/05/soap-envelope:Envelope' element is not declared.
My Request to 'GetStudentEntitlement'
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:adm="http://dest.gov.au/Heims/Admin/" xmlns:heim="http://dest.gov.au/Heims/">
<soap:Header/>
<soap:Body><adm:GetStudentEntitlement>
<heim:entitlementRequest>
<heim:RequestControlTable>
<heim:RequestId>CDD1E704-1298-4D42-AAD9-0031BB90329F</heim:RequestId>
<heim:ClientOrganisationCode>7591</heim:ClientOrganisationCode>
<heim:RequestLocalDateTime>2015-08-10T00:00:00</heim:RequestLocalDateTime>
</heim:RequestControlTable>
<heim:GetEntitlementIn>
<heim:RecordId>CDD1E704-1298-4D42-AAD9-0031BB90329F</heim:RecordId>
<heim:Chessn>1344</heim:Chessn>
<heim:FamilyName>Bassett</heim:FamilyName>
<heim:BirthDate>1988-05-21</heim:BirthDate>
</heim:GetEntitlementIn>
</heim:entitlementRequest>
</adm:GetStudentEntitlement>
</soap:Body>
</soap:Envelope>
The response:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<soap:Code>
<soap:Value>soap:Sender</soap:Value>
</soap:Code>
<soap:Reason>
<soap:Text xml:lang="en">Heims.WebServices.Extensions.Exceptions.XmlSchemaValidationException: Schema validation errors
at Heims.WebServices.Extensions.SoapFilterExtension.ValidateXmlMessage(SoapMessage message, WebMethodSettings methodSettings) in c:\Userdata\HEIMS.NET\Source\Development\WebService\Heims.WebService.Common\Extensions\SoapFilterExtension.cs:line 408
at Heims.WebServices.Extensions.SoapFilterExtension.ProcessMessageBeforeDeserialise(SoapMessage message) in c:\Userdata\HEIMS.NET\Source\Development\WebService\Heims.WebService.Common\Extensions\SoapFilterExtension.cs:line 200
at Heims.WebServices.Extensions.SoapFilterExtension.ProcessMessage(SoapMessage message) in c:\Userdata\HEIMS.NET\Source\Development\WebService\Heims.WebService.Common\Extensions\SoapFilterExtension.cs:line 173
at System.Web.Services.Protocols.SoapMessage.RunExtensions(SoapExtension[] extensions, Boolean throwOnException)
at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()</soap:Text>
</soap:Reason>
<detail>
<ValidationError>
<RecordId/>
<Element>Envelope</Element>
<Line>1</Line>
<Column>2</Column>
<Description>The 'http://www.w3.org/2003/05/soap-envelope:Envelope' element is not declared.</Description>
</ValidationError>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
I have tried adding and removing the trailing / on the :soap declaration, as well as trying both the 1.1 and 1.2 SOAP versions offered by this web service.
This endpoint request to 'Ping' works correctly:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:adm="http://dest.gov.au/Heims/Admin/">
<soap:Header/>
<soap:Body>
<adm:Ping/>
</soap:Body>
</soap:Envelope>
The result is returned as expected:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<PingResponse xmlns="http://dest.gov.au/Heims/Admin/">
<PingResult>Heims web services pinged. DateTime = 2015-08-10 11:11:00:05</PingResult>
</PingResponse>
</soap:Body>
</soap:Envelope>
So why would the code for one request (the ping) work perfectly, while the other request (GetStudentEntitlement) fails? Both have the soap:Envelope declaration, but the Ping request works fine.
I have also tried using xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" in the soap:Envelope element, but the error remained.
Is it possible that this is a server-side issue from the Web Service itself? Or is something simply going wrong in my code?
Answering my own question.
I contact the Government IT Assistance directly, and had them send me a code example. They were using a highly unusual and modified form of <soap wrapper, forcing me to manually generate the XML using SimpleXMLElement and submit to the Web Service using a wrapped SoapVar with the XSD_ANYXML type.
Did you get any solution to this...
I have encountered same problem today while converting UTL_DBWS utility (oracle plsql) to APEX utilities to make calls to HEIMS web service.
Ping worked but GetStudentEntitlements and AllocateStudentChessn both are failing with same envelop error.
Regards
RC
I want to read the SOAP request which is coming from a .NET WinForms application.
The request is:
<?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>
<HotelPricesRQ xmlns="http://zelsoft.ru/">
<HotelPricesRequest>
<Requestor Login="ZLS" Password="DE52F10D5089096E5D83CA559153D64824AAB0B4" />
<Conditions>
<Condition CityID="0" CountryID="0" HotelID="0" AccommodationID="0" RoomCategoryID="0" RoomTypeID="0">
<Created Begin="2013-10-31T00:00:00" End="2013-10-31T23:59:00+04:00" />
</Condition>
</Conditions>
</HotelPricesRequest>
</HotelPricesRQ>
</soap:Body>
</soap:Envelope>
So how to get the Requestor's Login, Password and the Creattion Begin Date?
I have actually build the response, we've test it and when they send me the request they got the response. I'm just sending the responce without reading the request, but I have to read it and log in diffrent users and send different response. So a real example with the request I've posted above will be much much appreciated.
I don't know why I didn't write the solution I got back then for reading the request,
but here it is, in case someone needs it:
$soap_request = file_get_contents("php://input");
Then I just parse it with the PHP XML Parser Functions like so:
$parser=xml_parser_create();
xml_parse_into_struct($parser,$soap_request,$request_array);
xml_parser_free($parser);
Now you have the data in the $request_array as an array.
You can also use The SimpleXMLElement class to get the data from the request.
this is what I generate using the SoapClient PHP class.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:sap-com:document:sap:soap:functions:mc-style">
<SOAP-ENV:Body>
<ns1:_-bic_-nf2>
<ETColumnDescription/>
<ETGridData/>
<ETMessageLog/>
<ETRowDescription/>
<ISVar_01xwerbet>
<Sign>I</Sign>
<Option>LE</Option>
<Low>3</Low>
<High/>
</ISVar_01xwerbet>
</ns1:_-bic_-nf2>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
What I also need is a blank header which should look like <SOAP-ENV:Header/>
right before <SOAP-ENV:Body>
But doing it with SOAPHeader: $header = new SOAPHeader('urn:sap-com:document:sap:soap:functions:mc-style',null,null) doesnt seem to be working. Tried everything. Any other ideas?
What I also need is, to remove the first line <?xml version="1.0" encoding="UTF-8"?> before sending the request, I think the server doesn't like it, would that be possible?
If it helps, this is for a SAP Web Service.
Thank you in advance.
It is possible. Just refer the nusoap.php file in libraries. You can modify the header which is normally present under the variable $headers.
I tried and it worked for me.
I'm using Zend_Soap_Client object for sending a soap request to another application here is the format of the XML that it's sending to the server:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="urllocation" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:enc="http://www.w3.org/2003/05/soap-encoding"><env:Body><ns1:isAccountActive env:encodingStyle="http://www.w3.org/2003/05/soap-encoding"><param0 xsi:type="xsd:string">thisisatest</param0></ns1:isAccountActive></env:Body></env:Envelope>
I'm using it on the other SOAP servers that I have and seems to work fine but one of the server returned a response "Invalid XML" that is why I'm really wondering why it won't work on that server alone. Any ideas would be greatly appreciated.
Additional Details:
I've tried to commentout the code that calls the method from the Server here is the code:
$client = new Zend_Soap_Client(null,
array(
'uri'=>'http://'.$user->customconfigs['alumniuri'],
'encoding'=>'UTF-8',
'location'=>'http://'.$user->customconfigs['alumnilocation']
)
);
echo "Location: {$user->customconfigs['alumnilocation']} - uri: {$user->customconfigs['alumniuri']}";
$alumniactive = $client->isAccountActive($token);
upon commenting out:
$alumniactive = $client->isAccountActive($token);
the error disappeared.This is the same codes from my other applications and it's working fine from there.
After a long search for the answer to this question I finally found the problem... this code is actually located on a joomla component which I was using the uri same as what I have from the location that would include a character "&" which is illegal on xml standards removing these character from my xml will then cause the SOAP server to accept the request as valid. :)