Link to home
Start Free TrialLog in
Avatar of Nilima-Mohite
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
Avatar of Sharon Seth
Sharon Seth
Flag of India image

Did you try to send in the same request as your customer and see if it works ?
Avatar of Nilima-Mohite
Nilima-Mohite

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 ?
Yes.
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--

Open in new window


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>

Open in new window



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

Open in new window



or:
com.sun.xml.internal.ws.server.UnsupportedMediaException: Unsupported Content-Type: text/html Supported ones are: [text/xml]

Open in new window

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
Was sending response as [updateDeliveryReturn]=response. 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

<?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>

Open in new window


& 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>

Open in new window

</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>

Open in new window

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

Open in new window

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

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>

Open in new window


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>

Open in new window



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?
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.
User generated image
When we call the service, we receive only the SOAP envelope.
User generated image
ASKER CERTIFIED SOLUTION
Avatar of mccarl
mccarl
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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|</updateDeliveryReturn>
      </updateDeliveryResponse>

It instead returns:
<ns1:updateDeliveryResponse xmlns:ns1="http://ourwebservice.domain.com/">
         <return xsi:type="xsd:string">100|2604574653|</return>
      </ns1:updateDeliveryResponse>

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->updateDeliveryReturn'
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.
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:updateDeliveryResponse xmlns:ns1="http://ourwebservice.domain.com/"><updateDeliveryReturn>'.$resp.'</updateDeliveryReturn></ns1:updateDeliveryResponse>';
            $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:Body><ns1:updateDeliveryResponse xmlns:ns1="http://ourwebservice.domain.com/"><updateDeliveryReturn>100|2604574653|
</updateDeliveryReturn></ns1:updateDeliveryResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>


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.
Hello, Update to above comment.
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/">

Open in new window

to
<ns1:updateDeliveryResponse xmlns="http://ourwebservice.domain.com/">

Open in new window


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--

Open in new window



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)

Open in new window

................................


Now who is at fault?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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...
<ns1:updateDeliveryResponse xmlns="http://ourwebservice.domain.com/">

Open in new window

You should really change this to remove the prefix too, such as...
<updateDeliveryResponse xmlns="http://ourwebservice.domain.com/">

Open in new window

(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;

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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
Thanks for all the help
Thanks for all the help
Not a problem. I'm glad that you were able to get to a solution! :)