Link to home
Start Free TrialLog in
Avatar of hbiz
hbiz

asked on

php soap request problem

I have the following web service I'd like to communicate with using php soap:

http://www.animplant.com/rmb/rmbService?wsdl

with the following php code:
<? php

$net = new SoapClient("http://www.animplant.com/rmb/rmbService?wsdl");
try{
        $result=$net->__soapCall('getResult', array('network'=>'10', 'x1'=>0.2, 'y1'=>0.2, 'x2'=>0.2, 'y2'=>0.2,
                                                                                    'x3'=>0.2, 'y3'=>0.2, 'x3'=>0.2, 'y3'=>0.2,
                                                                                    'x4'=>0.2, 'y4'=>0.2, 'x5'=>0.2, 'y5'=>0.2,
                                                                                    'x6'=>0.2, 'y6'=>0.2, 'x7'=>0.2, 'y7'=>0.2,
                                                                                    'x8'=>0.2, 'y8'=>0.2, 'x9'=>0.2, 'y9'=>0.2,
                                                                                    'x10'=>0.2, 'y10'=>0.2, 'x11'=>0.2, 'y11'=>0.2,
                                                                                    'x12'=>0.2, 'y12'=>0.2, 'x13'=>0.2, 'y13'=>0.2,
                                                                                    'x14'=>0.2, 'y14'=>0.2
                                                                  )
                                               )
                             ;
        print_r($result);
      }catch(Exception $e)
      {
        
          print_r($net->__getLastRequest());
      }
?>

Open in new window


That code constantly catches  a java.lang.NullPointerException from the service.

After some debugging, I found that my php soap object was not properly formatting the header as the service excepted and hence the null pointer issue.

I have access to this testing page to make sure that the service is working correctly:

http://www.animplant.com:8080/rmb/rmbService?Tester

if you plug in 0.2 in all of the fields of getResult and submit, you'll notice that it's working properly.

I was wondering if anyone could figure out what soap header format the getResult function requires and how I can get PHP to correctly pass that information to the service. I believe all the information can be deduced from the above code and links but let me know if you require more details.

Thanks for your time.

Avatar of djon2003
djon2003
Flag of Canada image

Could you post what you get from $net->__getLastRequest() ?
At http://www.animplant.com/rmb/ I see a JSP page with Hello World!  As I look at it, it raises a few questions...

Can you please step back from the technical details and tell us what this is all about, in general business terms?  There may be an easier way to skin this cat, if we know what kind of cat it is.  

Is there some other way you can communicate with the service, like a RESTful interface?  The online world is littered with failed SOAP requests, but I have never seen a REST interface that you could not understand and use immediately.
Avatar of hbiz
hbiz

ASKER

Here's the result of my getLastRequest:


<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://rmb.animplant.com/"><SOAP-ENV:Body><ns1:getResult/><param1>0.2</param1><param2>0.2</param2><param3>0.2</param3><param4>0.2</param4><param5>0.2</param5><param6>0.2</param6><param7>0.2</param7><param8>0.2</param8><param9>0.2</param9><param10>0.2</param10><param11>0.2</param11><param12>0.2</param12><param13>0.2</param13><param14>0.2</param14><param15>0.2</param15><param16>0.2</param16><param17>0.2</param17><param18>0.2</param18><param19>0.2</param19><param20>0.2</param20><param21>0.2</param21><param22>0.2</param22><param23>0.2</param23><param24>0.2</param24><param25>0.2</param25><param26>0.2</param26><param27>0.2</param27><param28>0.2</param28></SOAP-ENV:Body></SOAP-ENV:Envelope>


I'm told by the webservice owner that it should be as follows:

<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Header/>
    <S:Body>
        <ns2:getResult xmlns:ns2="http://rmb.animplant.com/
">
            <x1>0.2</x1>
            <y1>0.2</y1>
            <x2>0.2</x2>
            <y2>0.2</y2>
            <x3>0.2</x3>
            <y3>0.2</y3>
            <x4>0.2</x4>
            <y4>0.2</y4>
            <x5>0.2</x5>
            <y5>0.2</y5>
            <x6>0.2</x6>
            <y6>0.2</y6>
            <x7>0.2</x7>
            <y7>0.2</y7>
            <x8>0.2</x8>
            <y8>0.2</y8>
            <x9>0.2</x9>
            <y9>0.2</y9>
            <x10>0.2</x10>
            <y10>0.2</y10>
            <x11>0.2</x11>
            <y11>0.2</y11>
            <x12>0.2</x12>
            <y12>0.2</y12>
            <x13>0.2</x13>
            <y13>0.2</y13>
            <x14>0.2</x14>
            <y14>0.2</y14>
        </ns2:getResult>
    </S:Body>
</S:Envelope>


Any ideas how I can make php do that?

My guess is the soap _doRequest() function but I'm not sure of the specific details

thanks
I went to this page and plugged in 0.2 in all the fields of the top form then clicked "getResult" and it did not look like it was working correctly.  The code snippet contains the output after getResult.  I got similar results with addTrainingData and getTrainingData.
<HTML><HEAD><TITLE>Method invocation trace</TITLE></HEAD><H2><A> getResult </A> Method invocation</H2><BR><HR><h4>Method parameter(s)</h4><table border="1"><tr><th>Type</th><th>Value</th></tr><tr><td>java.lang.String</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr><tr><td>java.lang.Float</td><td>0.2</td></tr></table><HR><H2>Service invocation threw an exception with message : null; Refer to the server log for more details</H2><BR><HR><HTML><HEAD><TITLE>Method invocation exception</TITLE></HEAD><H3>Exceptions details : java.lang.reflect.InvocationTargetException</H3><HR>javax.servlet.ServletException: java.lang.reflect.InvocationTargetException
	at org.glassfish.webservices.monitoring.WebServiceTesterServlet.doPost(WebServiceTesterServlet.java:326)
	at org.glassfish.webservices.monitoring.WebServiceTesterServlet.invoke(WebServiceTesterServlet.java:102)
	at org.glassfish.webservices.JAXWSServlet.doPost(JAXWSServlet.java:137)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
	at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:239)
	at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
	at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
	at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
	at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
	at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
	at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
	at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
	at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
	at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
	at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
	at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
	at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.glassfish.webservices.monitoring.WebServiceTesterServlet.doPost(WebServiceTesterServlet.java:297)
	... 28 more
Caused by: javax.xml.ws.soap.SOAPFaultException: java.lang.NullPointerException
	at com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:189)
	at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:130)
	at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:119)
	at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89)
	at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:140)
	at $Proxy274.getResult(Unknown Source)
	... 33 more
Caused by: java.lang.NullPointerException
	at com.animplant.rmb.rmb.getResult(rmb.java:134)
	at sun.reflect.GeneratedMethodAccessor449.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.glassfish.webservices.InstanceResolverImpl$1.invoke(InstanceResolverImpl.java:137)
	at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:146)
	at com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:257)
	at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:95)
	at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:629)
	at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:588)
	at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:573)
	at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:470)
	at com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.process(AbstractTubeImpl.java:112)
	at org.glassfish.webservices.MonitoringPipe.process(MonitoringPipe.java:138)
	at com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:115)
	at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:629)
	at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:588)
	at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:573)
	at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:470)
	at com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.process(AbstractTubeImpl.java:112)
	at com.sun.enterprise.security.webservices.CommonServerSecurityPipe.processRequest(CommonServerSecurityPipe.java:195)
	at com.sun.enterprise.security.webservices.CommonServerSecurityPipe.process(CommonServerSecurityPipe.java:127)
	at com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:115)
	at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:629)
	at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:588)
	at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:573)
	at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:470)
	at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:295)
	at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:519)
	at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:288)
	at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:143)
	at org.glassfish.webservices.JAXWSServlet.doPost(JAXWSServlet.java:149)
	... 26 more

<HR></HTML>

Open in new window

Avatar of hbiz

ASKER

Oops, my mistake, the first parameter to getResult should be the number 10 and the rest can be all 0.2
OK, let's try this again:

Can you please step back from the technical details and tell us what this is all about, in general business terms?

Thank you, ~Ray
ASKER CERTIFIED SOLUTION
Avatar of hbiz
hbiz

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
Avatar of hbiz

ASKER

This is the solution provided by the service provider.