Nilima-Mohite
asked on
Help with SOAP webservice: PHP and Java.
Greetings Team,
We are creating a Webservice for a customer in WSDL mode. We develop in PHP, they work in Java. Our service, when we test with/out nusoap library in PHP works fine. But when the customer calls the service they get:
-Null response
-Unexpected format text/html, expected text/xml
-Error in msg parsing.
Do we need to recheck the WSDL? If this was the case, then it shouldnt work with PHP too.
We tried different permutations, combinations but they keep getting one of these cases.
How do we solve this? Attached WSDL.
Thank you in Advance.
Query.txt
We are creating a Webservice for a customer in WSDL mode. We develop in PHP, they work in Java. Our service, when we test with/out nusoap library in PHP works fine. But when the customer calls the service they get:
-Null response
-Unexpected format text/html, expected text/xml
-Error in msg parsing.
Do we need to recheck the WSDL? If this was the case, then it shouldnt work with PHP too.
We tried different permutations, combinations but they keep getting one of these cases.
How do we solve this? Attached WSDL.
Thank you in Advance.
Query.txt
Did you try to send in the same request as your customer and see if it works ?
ASKER
We asked them to send us a copy of the JAX-WS code. We are now trying to install Eclipse, Java and the related softwares to replicate the issue. Figuring out what softwares needed to do this,
I think you got me wrong . No need of installing all that . Did you actually test with the same input to the webservice ?
ASKER
Yes.
Their input is:
When we try to make a client and pass this as input, it works fine. We get the SOAP envelope in response:
Why they cant get the response is what we cant understand.
They get:
or:
Their input is:
--uuid:6035feb3-d1da-4493-b32b-7146115d0327
Content-Id: <rootpart*6035feb3-d1da-4493-b32b-7146115d0327@example.jaxws.sun.com>
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
Content-Transfer-Encoding: binary
<?xml version="1.0" encoding="UTF-8"?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><updateDelivery xmlns="http://ourwebservice.domain.com/><data>9861164345-98611643451391407829-20140219000000-test one-100003767</data><hashkey>2604574653</hashkey></updateDelivery></S:Body></S:Envelope>
--uuid:6035feb3-d1da-4493-b32b-7146115d0327--
When we try to make a client and pass this as input, it works fine. We get the SOAP envelope in response:
<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 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:Body><ns1:updateDeliveryResponse xmlns:ns1="http://ourwebservice.domain.com/"><return xsi:type="xsd:string">100|2604574653|
</return></ns1:updateDeliveryResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
Why they cant get the response is what we cant understand.
They get:
com.sun.xml.internal.ws.protocol.soap.MessageCreationException: Couldn't create SOAP message due to exception: unexpected XML tag. expected: {http://schemas.xmlsoap.org/soap/envelope/}Envelope but found: {null}updateDeliveryReturn
or:
com.sun.xml.internal.ws.server.UnsupportedMediaException: Unsupported Content-Type: text/html Supported ones are: [text/xml]
Any solution to this?
Is updateDeliveryReturn valid element in the input?
BTW , instead of installing eclipse and all , you can use SoapUI - java based web services util
ASKER
Was sending response as [updateDeliveryReturn]=res ponse. Removed that. Then they started getting 'null' is response.
We tested on SoapUI too.
Steps:
1) Create SOAP Project.
2) Give project name, enter the WSDL path.
3) It shows updateDelivery as method, with Request 1.
4) We added the input which we receive from client
& Click Run.
5) It gives response:
Hope we are doing the correct steps.
How can the customer pick up this response in Java? Please check the WSDL attached in the original question. The customer keeps asking us to update the WSDL and send the service. Why?
We tested on SoapUI too.
Steps:
1) Create SOAP Project.
2) Give project name, enter the WSDL path.
3) It shows updateDelivery as method, with Request 1.
4) We added the input which we receive from client
<?xml version="1.0" encoding="UTF-8"?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><updateDelivery xmlns="http://ourwebservice.domain.com/"><data>9861164345-98611643451391407829-20140219000000-test one-100003767</data><hashkey>2604574653</hashkey></updateDelivery></S:Body></S:Envelope>
& Click Run.
5) It gives response:
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 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:Body>
<ns1:updateDeliveryResponse xmlns:ns1="http://ourwebservice.domain.com/">
<return xsi:type="xsd:string">100|2604574653|</return>
</ns1:updateDeliveryResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>Hope we are doing the correct steps.
How can the customer pick up this response in Java? Please check the WSDL attached in the original question. The customer keeps asking us to update the WSDL and send the service. Why?
You said you gave the input in soapUI as :
<?xml version="1.0" encoding="UTF-8"?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><updateDelivery xmlns="http://ourwebservice.domain.com/"><data>9861164345-98611643451391407829-20140219000000-test one-100003767</data><hashkey>2604574653</hashkey></updateDelivery></S:Body></S:Envelope>
but in one of the earlier posts , you said customer request started with:--uuid:6035feb3-d1da-4493-b32b-7146115d0327
Content-Id: <rootpart*6035feb3-d1da-4493-b32b-7146115d0327@example.jaxws.sun.com>
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
Content-Transfer-Encoding: binary
ASKER
Hi,
Yes. The input received from the customer comes with this header information. If we point that out to them they say they are not doing anything to add the header information, it is as per our WSDL. How is that possible, beats us.
Even we had a tough time getting that header information out from the input and submitting only the SOAP envelope to our SOAP server.
But if the entire input with the header information is given to the SOAP server built using 'nusoap' library, it works.
We created a client in 'nusoap' library whose Request Response is as below:
Request
Response
Does this throw any light on the issue of why the customer cant get the Response in Java.
Thank you in advance !
Yes. The input received from the customer comes with this header information. If we point that out to them they say they are not doing anything to add the header information, it is as per our WSDL. How is that possible, beats us.
Even we had a tough time getting that header information out from the input and submitting only the SOAP envelope to our SOAP server.
But if the entire input with the header information is given to the SOAP server built using 'nusoap' library, it works.
We created a client in 'nusoap' library whose Request Response is as below:
Request
POST /PATH/delivery.php HTTP/1.0
Host: ourwebservice.domain.com/
User-Agent: NuSOAP/0.9.5 (1.123)
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: "OURWEBSERVICEservice#updateDelivery"
Content-Length: 558
<?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/" xmlns:ns2235="http://tempuri.org"><SOAP-ENV:Body><updateDelivery xmlns="http://ourwebservice.domain.com/"><data>9861164345-98611643451391407829-20140219000000-test one-100003767</data><hashkey>2604574653</hashkey></updateDelivery></SOAP-ENV:Body></SOAP-ENV:Envelope>
Response
HTTP/1.1 200 OK
Date: Thu, 03 Apr 2014 13:02:45 GMT
Server: Apache/2.0.55 (Unix) PHP/5.2.13
X-Powered-By: PHP/5.2.13
X-SOAP-Server: NuSOAP/0.9.5 (1.123)
Content-Length: 567
Connection: close
Content-Type: text/xml; charset=ISO-8859-1
<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 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:Body><ns1:updateDeliveryResponse xmlns:ns1="http://ourwebservice.domain.com/"><return xsi:type="xsd:string">100|2604574653|
</return></ns1:updateDeliveryResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
Does this throw any light on the issue of why the customer cant get the Response in Java.
Thank you in advance !
Is the webservice developed using NuSOAP / Whatever it is , webservices are supposed to be language independent . Also , when you pass the client's 'corrupt' request as is , what is the exception you see at the server side?
ASKER
Hi,
Please check the attached screenshots from SoupUI for valid and corrupt input.
In the current code we are using 'nusoap' library and not doing any processing to get the valid SOAP xml input.
Input is taken with :
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
This contains the header information when the customer calls the service.
When we call the service, we receive only the SOAP envelope.
Please check the attached screenshots from SoupUI for valid and corrupt input.
In the current code we are using 'nusoap' library and not doing any processing to get the valid SOAP xml input.
Input is taken with :
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA)
This contains the header information when the customer calls the service.
When we call the service, we receive only the SOAP envelope.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you mccarl. You are absolutely right. We have been sort of roaming around in the dark trying to hit the target without a clue.
We installed and executed the JAX-WS code. We too started getting 'null' in response.
This is because, as you pointed out the response as per the WSDL should have:
<updateDeliveryResponse xmlns="http://ourwebservice.domain.com/">
<updateDeliveryReturn xsi:type="xsd:string">100| 2604574653 |</updateD eliveryRet urn>
</updateDeliveryResponse>
It instead returns:
<ns1:updateDeliveryRespons e xmlns:ns1="http://ourwebservice.domain.com/">
<return xsi:type="xsd:string">100| 2604574653 |</return>
</ns1:updateDeliveryRespon se>
We cant figure out from where the 'return' element is coming from.
Solution as you say:
1) Change WSDL to return 'updateDeliveryReturn' instead of 'return->updateDeliveryRet urn'
2) Change service.
We tried both but still the same or worse errors keep coming up.
Can you suggest what in the WSDL needs to change.
The namespace : http://ourwebservice.domain.com/ is just a path from our servers.
Does this have to do anything with the buggy output? We are trying to keep the WSDL simple.
Should we do something to write a wrapper to change the SOAP response, correct it and send it out again? Dont know how to do that. Will be last resort.
Thank you for taking a look at the issue.
We installed and executed the JAX-WS code. We too started getting 'null' in response.
This is because, as you pointed out the response as per the WSDL should have:
<updateDeliveryResponse xmlns="http://ourwebservice.domain.com/">
<updateDeliveryReturn xsi:type="xsd:string">100|
</updateDeliveryResponse>
It instead returns:
<ns1:updateDeliveryRespons
<return xsi:type="xsd:string">100|
</ns1:updateDeliveryRespon
We cant figure out from where the 'return' element is coming from.
Solution as you say:
1) Change WSDL to return 'updateDeliveryReturn' instead of 'return->updateDeliveryRet
2) Change service.
We tried both but still the same or worse errors keep coming up.
Can you suggest what in the WSDL needs to change.
The namespace : http://ourwebservice.domain.com/ is just a path from our servers.
Does this have to do anything with the buggy output? We are trying to keep the WSDL simple.
Should we do something to write a wrapper to change the SOAP response, correct it and send it out again? Dont know how to do that. Will be last resort.
Thank you for taking a look at the issue.
ASKER
Hello Team,
Update !
We managed to get the updateDeliveryReturn node in the SOAP response.
This is by sort of pushing the XML nodes as response.
$output = '<ns1:updateDeliveryRespon se xmlns:ns1="http://ourwebservice.domain.com/"><updateDelive ryReturn>' .$resp.'</ updateDeli veryReturn ></ns1:upd ateDeliver yResponse> ';
$result = new SoapVar($output,XSD_ANYXML );
return $result;
The SOAP response now looks like:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ourwebservice.domain.com/"><SOAP-ENV:Bod y><ns1:upd ateDeliver yResponse xmlns:ns1="http://ourwebservice.domain.com/"><updateDelive ryReturn>1 00|2604574 653|
</updateDeliveryReturn></n s1:updateD eliveryRes ponse></SO AP-ENV:Bod y></SOAP-E NV:Envelop e>
But still the response from the service is 'null'
What is missing now? Do we HAVE to change the WSDL? If yes, then tell us where and how.
Please.
Thank you.
Update !
We managed to get the updateDeliveryReturn node in the SOAP response.
This is by sort of pushing the XML nodes as response.
$output = '<ns1:updateDeliveryRespon
$result = new SoapVar($output,XSD_ANYXML
return $result;
The SOAP response now looks like:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ourwebservice.domain.com/"><SOAP-ENV:Bod
</updateDeliveryReturn></n
But still the response from the service is 'null'
What is missing now? Do we HAVE to change the WSDL? If yes, then tell us where and how.
Please.
Thank you.
ASKER
Hello, Update to above comment.
The change was in the XML we were sending out as output:
so this was changed from:
We got the response for the this change.
But when the customer tests, the input is :
After this our service stops working.
The customer sends us error as:
......
Now who is at fault?
The change was in the XML we were sending out as output:
so this was changed from:
<ns1:updateDeliveryResponse xmlns:ns1="http://ourwebservice.domain.com/">
to<ns1:updateDeliveryResponse xmlns="http://ourwebservice.domain.com/">
We got the response for the this change.
But when the customer tests, the input is :
--uuid:dbe88e4b-4b0f-4662-823c-7f2bfd5f9b80
Content-Id: <rootpart*dbe88e4b-4b0f-4662-823c-7f2bfd5f9b80@example.jaxws.sun.com>
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
Content-Transfer-Encoding: binary
<?xml version="1.0" encoding="UTF-8"?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><updateDelivery xmlns="http://ourwebservice.domain.com/"><data>9861164345-98611643451391407829-20140219000000-test one-100003767,9861159602-98611596021391408014-20140219000000-test three-100003769,9861163442-98611634421391407911-20140219000000-test two-100003768</data><hashkey>2604574653</hashkey></updateDelivery></S:Body></S:Envelope>
--uuid:dbe88e4b-4b0f-4662-823c-7f2bfd5f9b80--
After this our service stops working.
The customer sends us error as:
javax.xml.ws.soap.SOAPFaultException: Bad Request
at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:190)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:123)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:120)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:90)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:119)
at $Proxy26.updateDelivery(Unknown Source)
..........................Now who is at fault?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oh, and the other thing that I was going to say... In your last post where you said that you fixed the namespace issue so that you sent this...
The entire code should look like this then...
<ns1:updateDeliveryResponse xmlns="http://ourwebservice.domain.com/">
You should really change this to remove the prefix too, such as...
<updateDeliveryResponse xmlns="http://ourwebservice.domain.com/">
(And obviously the same on the closing element. While you say that it already worked with this prefix, it is more correct to do it this way, and it would remove the possibility of latent issues that may come up in the future.The entire code should look like this then...
$output = '<updateDeliveryResponse xmlns="http://ourwebservice.domain.com/"><updateDeliveryReturn>'.$resp.'</updateDeliveryReturn></updateDeliveryResponse>';
$result = new SoapVar($output,XSD_ANYXML);
return $result;
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I've requested that this question be closed as follows:
Accepted answer: 0 points for Nilima-Mohite's comment #a39991386
for the following reason:
Worked around after a lot of trial and error
Accepted answer: 0 points for Nilima-Mohite's comment #a39991386
for the following reason:
Worked around after a lot of trial and error
I am happy with the asker accepting his answer as the solution, but I thought that my contribution (http:#a39987692) would at least deserve some "assist" points, especially as the asker says...
Thank you mccarl. Your pointing out the issues was helpful in looking for the correct solution
ASKER
Thanks for all the help
Thanks for all the helpNot a problem. I'm glad that you were able to get to a solution! :)