Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Parameters to a java web service are always null

843833Feb 8 2007 — edited Feb 9 2007
Hello

I have writing a java webservice and I am attempting to call it via soap from IE.

The issue I am having is that the parameters passed to the webservice are always null. The return parameter (hardcoded for testing) works fine.

The following is the source to my web service

package org.me.calculator;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
//import javax.jws.soap.SOAPBinding;

@WebService(wsdlLocation="WEB-INF/wsdl/CalculatorWS.wsdl")
//@SOAPBinding(style=SOAPBinding.Style.DOCUMENT,use=SOAPBinding.Use.LITERAL,parameterStyle=SOAPBinding.ParameterStyle.WRAPPED)
public class CalculatorWS {
/**
* Web service operation
*/
@WebMethod(action="add",operationName="add")
public String add(java.lang.String one, java.lang.String two) {

return "bob";
}

}

You'll notice that the soapbinding statements are commented. The results with them in where no different.

The following is the wsdl for the service

<wsdl:definitions
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tns="http://calculator.me.org/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
targetNamespace="http://calculator.me.org/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
name="CalculatorWSService" >
<wsdl:types>
<s:schema targetNamespace="http://calculator.me.org/" elementFormDefault="qualified">
<s:element name="add">
<s:complexType>
<s:sequence>
<s:element name="one" type="s:string" minOccurs="0" maxOccurs="1" />
<s:element name="two" type="s:string" minOccurs="0" maxOccurs="1" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="addResponse" >
<s:complexType>
<s:sequence>
<s:element name="return" type="s:string" minOccurs="0" maxOccurs="1" />
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="add">
<wsdl:part element="tns:add" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="addResponse">
<wsdl:part element="tns:addResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:portType name="CalculatorWS">
<wsdl:operation name="add">
<wsdl:input message="tns:add"></wsdl:input>
<wsdl:output message="tns:addResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CalculatorWSPortBinding" type="tns:CalculatorWS">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"></soap:binding>
<wsdl:operation name="add">
<soap:operation soapAction="http://calculator.me.org/add" style="document"></soap:operation>
<wsdl:input>
<soap:body use="literal"></soap:body>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"></soap:body>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="CalculatorWSService">
<wsdl:port name="CalculatorWSPort" binding="tns:CalculatorWSPortBinding">
<soap:address location="http://127.0.0.1:8084/CalculatorWSApplication/CalculatorWS"></soap:address>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

I choice to create the wsdl instead of having NetBeans create it (the one created by NetBeans was used as the basis). The reason for this is that the wsdl is also needed on the client (IE) and the wsdl created by NetBeans does an xml include method that does not deliver the included peice to IE.

The next part is the wsdl being delivered to the web client IE

<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://calculator.me.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://calculator.me.org/" name="CalculatorWSService">
<wsdl:types>
<s:schema targetNamespace="http://calculator.me.org/" elementFormDefault="qualified">
<s:element name="add">
<s:complexType>
<s:sequence>
<s:element maxOccurs="1" name="one" type="s:string" minOccurs="0"></s:element>
<s:element maxOccurs="1" name="two" type="s:string" minOccurs="0"></s:element>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="addResponse">
<s:complexType>
<s:sequence>
<s:element maxOccurs="1" name="return" type="s:string" minOccurs="0"></s:element>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="add">
<wsdl:part element="tns:add" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="addResponse">
<wsdl:part element="tns:addResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:portType name="CalculatorWS">
<wsdl:operation name="add">
<wsdl:input message="tns:add"></wsdl:input>
<wsdl:output message="tns:addResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CalculatorWSPortBinding" type="tns:CalculatorWS">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"></soap:binding>
<wsdl:operation name="add">
<soap:operation style="document" soapAction="http://calculator.me.org/add"></soap:operation>
<wsdl:input>
<soap:body use="literal"></soap:body>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"></soap:body>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="CalculatorWSService">
<wsdl:port name="CalculatorWSPort" binding="tns:CalculatorWSPortBinding">
<soap:address location="http://10.5.5.51:8084/CalculatorWSApplication/CalculatorWS"></soap:address>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

The next part is the soap message to the web service

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><add xmlns="http://calculator.me.org/"><one>Matteo</one><two>Matteo</two></add></soap:Body></soap:Envelope>

The next part is the screen image of NetBeans code break



You can see that the code stop at my break line which clearly indicates the the call from IE to the web service (in basic form) is working part the parameters are always passed as null values.

The next peice is the return soap from the web service. Take notice the the image above shows the return value should be 'bob'

<?xml version="1.0" ?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://calculator.me.org/"><soapenv:Body><ns1:addResponse><return>bob</return></ns1:addResponse></soapenv:Body></soapenv:Envelope>

In the above you'll see the return value is in fact 'bob'

Does any one know why the parameters are always passed as null?

Bob Jenkin
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 9 2007
Added on Feb 8 2007
1 comment
1,075 views