I've made a WS server from a WSDL definition (Contract first approach).
I've generated the Java artifacts with wsimport and tested the service.
Now I've got a problem. Some (not all) arguments of an operation requests are unmarshalled as null!
The web service is SOAP based. The wsdl follow the document-literal convention.
So, this is the schema imported by AbstractFDSInfo.wsdl:
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.example.com/FDSControl"
xmlns:com="http://www.example.com/FDSCommon"
targetNamespace="http://www.example.com/FDSControl"
elementFormDefault="qualified">
<import namespace="http://www.example.com/FDSCommon" schemaLocation="FDSCommon.xsd"/>
<complexType name="PassengerList">
<sequence>
<element ref="com:Passenger" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>
<complexType name="FlightInstanceStatusList">
<sequence>
<element type="com:flightInstanceStatus" name="Status" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>
<!-- other operation types here -->
<element name="setPassengerBoarded">
<complexType>
<sequence>
<element ref="com:FlightInstanceId"/>
<element type="string" name="Passenger"/>
</sequence>
</complexType>
</element>
<element name="setPassengerBoardedResponse">
<complexType/>
</element>
<element name="passengerBoardingException">
<complexType>
<sequence>
<element type="token" name="Reason"/>
<element type="string" name="Detail"/>
</sequence>
</complexType>
</element>
<!-- Other operation types here --->
And here is the FDSControlAbstract.wsdl:
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="FDSControlAbstract"
xmlns:tns="http://www.example.com/FDSControl.wsdl"
xmlns:con="http://www.example.com/FDSControl"
xmlns:com="http://www.example.com/FDSCommon"
xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://www.example.com/FDSControl.wsdl">
<types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.example.com/FDSCommon" schemaLocation="FDSCommon.xsd"/>
<xsd:import namespace="http://www.example.com/FDSControl" schemaLocation="FDSControl.xsd"/>
</xsd:schema>
</types>
<message name="setPassengerBoardedRequest">
<part element="con:setPassengerBoarded" name="Params"/>
</message>
<message name="setPassengerBoardedResponse">
<part element="con:setPassengerBoardedResponse" name="Params"/>
</message>
<message name="passengerBoardingException">
<part element="con:passengerBoardingException" name="Params"/>
</message>
<!-- other messages here -->
<portType name="FDSBoardingPortType">
<!-- other operations here -->
<operation name="setPassengerBoarded">
<documentation>
Sets a passenger as boarded. If the passenger is already boarded,
or the flight instance is not in the boarding status, an exception
is returned.
</documentation>
<input message="tns:setPassengerBoardedRequest"/>
<output message="tns:setPassengerBoardedResponse"/>
<fault message="tns:flightInstanceNotFoundException"
name="flightInstanceNotFoundException"/>
<fault message="tns:passengerBoardingException"
name="passengerBoardingException"/>
<fault message="tns:flightStatusException"
name="flightStatusException"/>
</operation>
</portType>
<!-- other port types here -->
</definitions>
Here is the FDSControl.wsdl:
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="FDSControl"
xmlns:tns="http://www.example.com/FDSControl.wsdl"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://www.example.com/FDSControl.wsdl"
elementFormDefault="qualified">
<import namespace="http://www.example.com/FDSControl.wsdl" location="FDSControlAbstract.wsdl"/>
<!-- other bindings here-->
<binding name="FDSBoardingSOAP" type="tns:FDSBoardingPortType">
<!-- other operations here -->
<operation name="setPassengerBoarded">
<soap:operation soapAction="http://www.example.com/FDSControl/setPassengerBoarded"/>
<input> <soap:body use="literal"/> </input>
<output> <soap:body use="literal"/> </output>
<fault name="flightInstanceNotFoundException">
<soap:fault name="flightInstanceNotFoundException" use="literal"/>
</fault>
<fault name="passengerBoardingException">
<soap:fault name="passengerBoardingException" use="literal"/>
</fault>
<fault name="flightStatusException">
<soap:fault name="flightStatusException" use="literal"/>
</fault>
</operation>
</binding>
<service name="FDSBoardingSOAPService">
<port name="FDSBoardingPortType" binding="tns:FDSBoardingSOAP">
<soap:address location="http://localhost:7070/fdscontrol"/>
</port>
</service>
</definitions>
Now here is the definition of the java class implementing the web service:
#WebService(name="FDSBoarding",
endpointInterface="it.polito.dp2.FDS.lab4.server.gen.FDSBoardingPortType",
wsdlLocation="META-INF/FDSControl.wsdl",
portName="FDSBoardingPortType",
serviceName="FDSBoardingSOAPService",
targetNamespace="http://www.example.com/FDSControl.wsdl")
})
public class FDSControlImpl implements FDSBoardingPortType {
private FlightManager manager;
public FDSControlImpl(FlightManager manager) {
this.manager = manager;
}
//other methods here
#Override
public SetPassengerBoardedResponse setPassengerBoarded(SetPassengerBoarded params)
throws FlightInstanceNotFoundException_Exception, FlightStatusException_Exception, PassengerBoardingException_Exception {
return manager.setPassengerBoarded(params);
}
}
You can see I kept the parameters wrapped in a single class.
Now the problem is that, whenever I send a request for setPassengerBoarded(), the server returns null as params.getPassenger()
Is there something wrong with my structure/definitions?
I do not have commenting privileges. I would suggest that first test the web service through SOAP UI.
You would then be sure whether the service is working as you expect or some parameters need to change.
If your test is successful then try to set the same parameters in the proxy.
I was compiling two different WSDLs to the same package. I split the generated code in two packages and the problem disappeared, even though now I have duplicate classes and thus I need to convert back and forth between the these...
Related
I have the web service url
http://seguriteca.sir.renfe.es/u35/GDN/Seguriteca2017/Normativa.nsf/DegradadoMercancias
and I want to get the wsdl to obtain the java classes from java.
How can I get the wsdl?
Edited.
I attach my wsdl. I want to know which are the java classes generated from this wsdl
<?xml version="1.0" encoding="UTF-8"?>
<definitions targetNamespace="urn:DefaultNameSpace"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="urn:DefaultNameSpace" xmlns:intf="urn:DefaultNameSpace"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<schema targetNamespace="urn:DefaultNameSpace"
xmlns="http://www.w3.org/2001/XMLSchema">
<element name="LINEAS" type="xsd:string" />
<element name="TRAMOS" type="xsd:string" />
<element name="CODUSUARIO" type="xsd:string" />
<element name="NOMUSUARIO" type="xsd:string" />
<complexType name="LISTADO">
<sequence>
<element name="RESULTADO" type="xsd:string" />
<element name="MSG" type="xsd:string" />
</sequence>
</complexType>
<element name="LISTADODOCUMENTOSReturn" type="impl:LISTADO" />
</schema>
</wsdl:types>
<message name="LISTADODOCUMENTOSRequest">
<part element="impl:LINEAS" name="LINEAS" />
<part element="impl:TRAMOS" name="TRAMOS" />
<part element="impl:CODUSUARIO" name="CODUSUARIO" />
<part element="impl:NOMUSUARIO" name="NOMUSUARIO" />
</message>
<message name="LISTADODOCUMENTOSResponse">
<part element="impl:LISTADODOCUMENTOSReturn"
name="LISTADODOCUMENTOSReturn" />
</message>
<portType name="DegradadoMercanciasNotes">
<operation name="LISTADODOCUMENTOS">
<input message="impl:LISTADODOCUMENTOSRequest"
name="LISTADODOCUMENTOSRequest" />
<output message="impl:LISTADODOCUMENTOSResponse"
name="LISTADODOCUMENTOSResponse" />
</operation>
</portType>
<binding name="DominoSoapBinding"
type="impl:DegradadoMercanciasNotes">
<wsdlsoap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="LISTADODOCUMENTOS">
<wsdlsoap:operation soapAction="" />
<input name="LISTADODOCUMENTOSRequest">
<wsdlsoap:body use="literal" />
</input>
<output name="LISTADODOCUMENTOSResponse">
<wsdlsoap:body use="literal" />
</output>
</operation>
</binding>
<service name="DegradadoMercanciasNotesService">
<port binding="impl:DominoSoapBinding" name="Domino">
<wsdlsoap:address
location="http://seguriteca.sir.renfe.es:80/u35/GDN/Seguriteca2017/Normativa.nsf/DegradadoMercancias?OpenWebService" />
</port>
</service>
</definitions>
It depends on the framework been used for Web Service implementation.
Usually you can find it appending "?wsdl" or ".wsdl" to the web service URL.
So, I would try with http://seguriteca.sir.renfe.es/u35/GDN/Seguriteca2017/Normativa.nsf/DegradadoMercancias?wsdl or http://seguriteca.sir.renfe.es/u35/GDN/Seguriteca2017/Normativa.nsf/DegradadoMercancias.wsdl
I am creating the web-service with the use of SOAP & WSDL. After creating WSDL I am generating the "Java bean skeleton" using eclipse. From the generated stubs I can able to call the web-service from IOS app.
In the web-service response I am returning the complex data type to the user. The problem is,
I am getting the unique response tag for the complex type as given below.
My WSDL is,
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://service.cmp.app.com" xmlns:intf="http://service.cmp.app.com" xmlns:tns1="http://request.cmp.app.com" xmlns:tns2="http://response.cmp.app.com" xmlns:tns3="http://bean.cmp.app.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://service.cmp.app.com">
<!--WSDL created by Apache Axis version: 1.4 Built on Apr 22, 2006 (06:55:48
PDT) -->
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://service.cmp.app.com">
<import namespace="http://response.cmp.app.com"/>
<import namespace="http://request.cmp.app.com"/>
<import namespace="http://bean.cmp.app.com"/>
<element name="ViewAppTrack">
<complexType>
<sequence>
<element name="ViewAppTrackRequest" type="tns1:ViewAppTrackRequest"/>
</sequence>
</complexType>
</element>
<element name="ViewAppTrackResponse">
<complexType>
<sequence>
<element name="ViewAppTrackResponseReturn" type="tns2:ViewAppTrackResponse"/>
</sequence>
</complexType>
</element>
<complexType name="ArrayOf_tns3_MonthListBO">
<sequence>
<element maxOccurs="unbounded" minOccurs="0" name="monthListItem" type="tns3:MonthListBO"/>
</sequence>
</complexType>
<complexType name="ArrayOf_tns3_TaskListBO">
<sequence>
<element maxOccurs="unbounded" minOccurs="0" name="taskListItem" type="tns3:TaskListBO"/>
</sequence>
</complexType>
</schema>
<schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://request.cmp.app.com">
<import namespace="http://response.cmp.app.com"/>
<import namespace="http://service.cmp.app.com"/>
<import namespace="http://bean.cmp.app.com"/>
<complexType name="ViewAppTrackRequest">
<sequence>
<element name="userId" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
</schema>
<schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://bean.cmp.app.com">
<import namespace="http://response.cmp.app.com"/>
<import namespace="http://service.cmp.app.com"/>
<import namespace="http://request.cmp.app.com"/>
<complexType name="MonthListBO">
<sequence>
<element name="date" nillable="true" type="xsd:string"/>
<element name="lockStatus" nillable="true" type="xsd:string"/>
<element name="dailyTime" nillable="true" type="xsd:string"/>
<element name="taskListNew" nillable="true" type="impl:ArrayOf_tns3_TaskListBO"/>
</sequence>
</complexType>
<complexType name="TaskListBO">
<sequence>
<element name="trackId" type="xsd:int"/>
<element name="taskId" type="xsd:int"/>
<element name="trackDate" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
</schema>
<schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://response.cmp.app.com">
<import namespace="http://service.cmp.app.com"/>
<import namespace="http://request.cmp.app.com"/>
<import namespace="http://bean.cmp.app.com"/>
<complexType name="ViewAppTrackResponse">
<sequence>
<element name="monthBO" nillable="true" type="impl:ArrayOf_tns3_MonthListBO"/>
<element name="userId" nillable="true" type="xsd:string"/>
<element name="projectId" nillable="true" type="xsd:string"/>
<element name="customerId" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="ViewAppTrackRequest">
<wsdl:part element="impl:ViewAppTrack" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="ViewAppTrackResponse">
<wsdl:part element="impl:ViewAppTrackResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="AppWeb">
<wsdl:operation name="ViewAppTrack">
<wsdl:input message="impl:ViewAppTrackRequest" name="ViewAppTrackRequest">
</wsdl:input>
<wsdl:output message="impl:ViewAppTrackResponse" name="ViewAppTrackResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="AppWebSoapBinding" type="impl:AppWeb">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="ViewAppTrack">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="ViewAppTrackRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="ViewAppTrackResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="AppWebService">
<wsdl:port binding="impl:AppWebSoapBinding" name="AppWeb">
<wsdlsoap:address location="http://localhost:8080/test/services/AppWeb"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
And my request XML is,
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.cmp.app.com" xmlns:req="http://request.cpm.app.com">
<soapenv:Header/>
<soapenv:Body>
<ser:ViewAppTrack>
<ser:ViewAppTrackRequest>
<req:userId>5</req:userId>
</ser:ViewAppTrackRequest>
</ser:ViewAppTrack>
</soapenv:Body>
</soapenv:Envelope>
The following response I am getting,
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ViewAppTrackResponse xmlns="http://service.cmp.app.com">
<ViewAppTrackResponseReturn>
<ns1:monthBO xmlns:ns1="http://response.cmp.app.com">
<monthListItem>
<ns2:date xmlns:ns2="http://bean.cmp.app.com">1-2-2014, Saturday (nonworking day)</ns2:date>
<ns3:lockStatus xmlns:ns3="http://bean.cmp.app.com">N</ns3:lockStatus>
<ns4:dailyTime xsi:nil="true" xmlns:ns4="http://bean.cmp.app.com"/>
<ns5:taskListNew xsi:nil="true" xmlns:ns5="http://bean.cmp.app.com"/>
</monthListItem>
<monthListItem>
<ns6:date xmlns:ns6="http://bean.cmp.app.com">2-2-2014, Sunday (nonworking day)</ns6:date>
<ns7:lockStatus xmlns:ns7="http://bean.cmp.app.com">N</ns7:lockStatus>
<ns8:dailyTime xmlns:ns8="http://bean.cmp.app.com">04:00</ns8:dailyTime>
<ns9:taskListNew xmlns:ns9="http://bean.cmp.app.com">
<taskListItem>
<ns9:trackId>1070</ns9:trackId>
<ns9:taskId>14</ns9:taskId>
</taskListItem>
<taskListItem>
<ns9:trackId>1094</ns9:trackId>
<ns9:taskId>44</ns9:taskId>
</taskListItem>
</ns9:taskListNew>
</monthListItem>
<monthListItem>
<ns10:date xmlns:ns10="http://bean.cmp.app.com">3-2-2014, Monday</ns10:date>
<ns11:lockStatus xmlns:ns11="http://bean.cmp.app.com">N</ns11:lockStatus>
<ns12:dailyTime xmlns:ns12="http://bean.cmp.app.com">08:00</ns12:dailyTime>
<ns13:taskListNew xmlns:ns13="http://bean.cmp.app.com">
<taskListItem>
<ns13:trackId>1071</ns13:trackId>
<ns13:taskId>14</ns13:taskId>
</taskListItem>
<taskListItem>
<ns13:trackId>1073</ns13:trackId>
<ns13:taskId>44</ns13:taskId>
</taskListItem>
</ns13:taskListNew>
</monthListItem>
</ns1:monthBO>
<ns14:userId xsi:nil="true" xmlns:ns114="http://response.cmp.app.com"/>5</ns14:userId>
</ViewAppTrackResponseReturn>
</ViewAppTrackResponse>
</soapenv:Body>
</soapenv:Envelope>
The problem:
I am getting the above XML response as same tag like monthListItem, taskListItem.
(i.e,) monthBO ->
monthListItem -> taskListItem, taskListItem, etc...,
monthListItem -> taskListItem, taskListItem, etc...,
monthListItem -> taskListItem, taskListItem, etc...,
etc...
Can I change the response like below. So that I can parse this response from IOS.
(i.e,) monthBO ->
monthListItem1 -> taskListItem1, taskListItem2
monthListItem2 -> taskListItem3, taskListItem4
monthListItem3 -> taskListItem5, taskListItem6
etc...
Or is it possible to parse the complex type response data in IOS?
I am trying to access a java webservice by sending a soap request to the service
the strange part is that until recently it worked fine, and now it gives me an internal server error
what am i doing wrong ??
this is my soap message:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://webservice.lenabru.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <q0:register><q0:regFirstName></q0:regFirstName><q0:regLastName></q0:regLastName><q0:regLoginName></q0:regLoginName><q0:regPassword></q0:regPassword><q0:regAddress></q0:regAddress><q0:regEmail></q0:regEmail><q0:regPhone></q0:regPhone></q0:register></soapenv:Body></soapenv:Envelope>
and this is the response i get from the server
"<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>java.lang.reflect.InvocationTargetException</faultstring>
<detail>
<ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">Lena</ns1:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>"
this is the contents of the webmethod i am trying to reach:
#WebMethod
public boolean register(String regFirstName, String regLastName, String regLoginName, String regPassword, String regAddress, String regPhone, String regEmail) {
return false;
}
this is my wsdl:
<wsdl:definitions xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://webservice.lenabru.com" xmlns:intf="http://webservice.lenabru.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://webservice.lenabru.com">
<!--
WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)
-->
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://webservice.lenabru.com">
<element name="register">
<complexType>
<sequence>
<element name="regFirstName" type="xsd:string"/>
<element name="regLastName" type="xsd:string"/>
<element name="regLoginName" type="xsd:string"/>
<element name="regPassword" type="xsd:string"/>
<element name="regAddress" type="xsd:string"/>
<element name="regPhone" type="xsd:string"/>
<element name="regEmail" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="registerResponse">
<complexType>
<sequence>
<element name="registerReturn" type="xsd:boolean"/>
</sequence>
</complexType>
</element>
<element name="isUserExists">
<complexType>
<sequence>
<element name="userName" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="isUserExistsResponse">
<complexType>
<sequence>
<element name="isUserExistsReturn" type="xsd:boolean"/>
</sequence>
</complexType>
</element>
</schema>
</wsdl:types>
<wsdl:message name="isUserExistsResponse">
<wsdl:part element="impl:isUserExistsResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="registerRequest">
<wsdl:part element="impl:register" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="isUserExistsRequest">
<wsdl:part element="impl:isUserExists" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="registerResponse">
<wsdl:part element="impl:registerResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:portType name="ElectronicArenaWebService">
<wsdl:operation name="register">
<wsdl:input message="impl:registerRequest" name="registerRequest"></wsdl:input>
<wsdl:output message="impl:registerResponse" name="registerResponse"></wsdl:output>
</wsdl:operation>
<wsdl:operation name="isUserExists">
<wsdl:input message="impl:isUserExistsRequest" name="isUserExistsRequest"></wsdl:input>
<wsdl:output message="impl:isUserExistsResponse" name="isUserExistsResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ElectronicArenaWebServiceSoapBinding" type="impl:ElectronicArenaWebService">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="register">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="registerRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="registerResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="isUserExists">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="isUserExistsRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="isUserExistsResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ElectronicArenaWebServiceService">
<wsdl:port binding="impl:ElectronicArenaWebServiceSoapBinding" name="ElectronicArenaWebService">
<wsdlsoap:address location="http://localhost:8080/ElectronicArenaLena/services/ElectronicArenaWebService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
First a note: if you're using Tomcat 7 (why not use Axis 2 ?)
Setup for Log4j (at the time axis 1 was still there there was log4j, now there is a better alternatives from the same author of Log4j it's called logback - however there is a new Log4j 2 now but I haven't tested it for this setup only the one that comes with axis downloaded here
http://archive.apache.org/dist/ws/axis/1_4/)
create a log4j.properties file and put it in your WEB-INF/classes folder
(I created a sample content so that you can get going, might need to look at log4j's documentation to modify the logs as you need - the below creates multiple log files(max 5) whenever one's size reaches 100k it creates another, you might need to change the size or number as needed or just use one)
log4j.rootLogger=DEBUG, R
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.MaxFileSize=100KB
log4j.appender.R.File=axis.log
log4j.appender.R.MaxBackupIndex=5
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} – %m%n
# below line might not be needed, but I just had it there
log4j.R.org.apache.axis=DEBUG
now open axis.jar and remove whatever properties file you have directly in the folder structure (next to MANIFEST and org folders - I had simplelog.properties so I deleted it)
restart apache tomcat and check the apache logs to make sure log4j isn't throwing any warnings or errors
If everything works fine, you should be able to see axis.log in apache tomcat's bin directory
Note:
you might notice a lot of useless debug logs, however when an exception occurs or some issue happens it might be handy to have this level of details in your logs, plus you can disable it anytime you need, just replace rootLogger DEBUG into INFO or comment log4j.properties all together
References:
http://osdir.com/ml/text.xml.axis.user/2002-08/msg00436.html
http://axis.apache.org/axis/java/developers-guide.html#LoggingTracing
I am trying to develop a web service with axis2. The problem is that I don't get the parameters passed in the url for an http Binding.
Here is my service.xml :
<parameter name="ServiceClass">my.package.MyClass
</parameter>
<operation name="getUser">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
<parameter name="useOriginalwsdl">true</parameter>
Here is my simplified wsdl :
<definitions ...>
<types>
<schema ...>
<complexType name="User">
<sequence>
<element name="id" type="string"/>
<element name="age" type="int"/>
</sequence>
</complexType>
<element name="getUser">
<complexType>
<sequence>
<element name="id" type="xs:string" form="unqualified" />
</sequence>
</complexType>
</element>
<element name="getUserResponse">
<complexType>
<sequence>
<element name="user" nillable="true"
type="user" />
</sequence>
</complexType>
</element>
</schema>
</types>
<message name="getUserRequest">
<part name="parameters" element="getUser" />
</message>
<message name="getUserResponse">
<part name="parameters" element="getUserResponse" />
</message>
<portType name="testPortType">
<operation name="getUser">
<input message="getUserRequest"
Action="urn:getUser" />
<output message="getUserResponse"
Action="urn:getUserResponse" />
</operation>
</portType>
<binding name="testHttpBinding" type="testPortType">
<binding verb="GET" />
<operation name="getUser">
<http:operation location="getUser" />
<input>
<http:urlEncoded />
<input>
<output>
<mime:content type="text/xml" />
</output>
</operation>
</binding>
<service name="test">
<port name="testHttpEndpoint" binding="testHttpBinding">
<address
location="http://localhost:8080/axis2/services/test.testHttpEndpoint/" />
</port>
</service>
</definitions>
and finally my.package.MyClass :
public final class MyClass {
public User getUser(String id) {
//Do something
}
}
When I call the service with the request http://urlToService/getUser?id=test, I enter in getUser(String id) but the id is null.
Does someone know how am I supposed to fix that?
Thank you
In fact I was doing something wrong.
In MyClass, I am not supposed to do :
public User getUser(String id){
}
but
public User getUser(GetUser getUser){
}
as written in the wsdl file.
Can any one figure out my problem is...
I'm calling a webmethod of a Java Webservice (Axis 1.4) from a .Net client. That method returns a Map object, and if i call it from an Axis client works fine, but in my c# code it´s always null.
That's the WSDL:
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="urn:http.service.enlaces.portlet.ext.com" xmlns:intf="urn:http.service.enlaces.portlet.ext.com" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://model.enlaces.portlet.ext.com" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:http.service.enlaces.portlet.ext.com">
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xml.apache.org/xml-soap">
<import namespace="urn:http.service.enlaces.portlet.ext.com"/>
<import namespace="http://model.enlaces.portlet.ext.com"/>
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="mapItem">
<sequence>
<element name="key" nillable="true" type="xsd:anyType"/>
<element name="value" nillable="true" type="xsd:anyType"/>
</sequence>
</complexType>
<complexType name="Map">
<sequence>
<element maxOccurs="unbounded" minOccurs="0" name="item" type="apachesoap:mapItem"/>
</sequence>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="getFoldersAndBookmarksRequest" />
<wsdl:message name="getFoldersAndBookmarksResponse">
<wsdl:part name="getFoldersAndBookmarksReturn" type="apachesoap:Map" />
</wsdl:message>
<wsdl:portType name="BookmarksEntryServiceSoap">
<wsdl:operation name="getFoldersAndBookmarks">
<wsdl:input name="getFoldersAndBookmarksRequest" message="intf:getFoldersAndBookmarksRequest" />
<wsdl:output name="getFoldersAndBookmarksResponse" message="intf:getFoldersAndBookmarksResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="Portlet_Bookmarks_BookmarksEntryServiceSoapBinding" type="intf:BookmarksEntryServiceSoap">
<wsdlsoap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" />
<wsdl:operation name="getFoldersAndBookmarks">
<wsdlsoap:operation soapAction="" />
<wsdl:input name="getFoldersAndBookmarksRequest">
<wsdlsoap:body use="encoded" namespace="urn:http.service.enlaces.portlet.ext.com" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</wsdl:input>
<wsdl:output name="getFoldersAndBookmarksResponse">
<wsdlsoap:body use="encoded" namespace="urn:http.service.enlaces.portlet.ext.com" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
and my c# auto-generated code:
[System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="urn:http.service.enlaces.portlet.ext.com", ResponseNamespace="urn:http.service.enlaces.portlet.ext.com")]
[return: System.Xml.Serialization.SoapElementAttribute("getFoldersAndBookmarksReturn")]
public Map getFoldersAndBookmarks() {
object[] results = this.Invoke("getFoldersAndBookmarks", new object[0]);
return ((Map)(results[0]));
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.3082")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.SoapTypeAttribute(Namespace="http://xml.apache.org/xml-soap")]
public partial class Map {
private mapItem[] itemField;
/// <comentarios/>
public mapItem[] item {
get {
return this.itemField;
}
set {
this.itemField = value;
}
}
}
I,ve seen everywhere unfortunately, i don't find the solution.
Please, there are anyone what knows it?
I've faced the same problem a while ago. This happens when you try to get an array of elements through an axis webservice with a .net client.
The problem is "name=item" part of this line :
<element maxOccurs="unbounded" minOccurs="0" name="item" type="apachesoap:mapItem"/>
Try changing in that particular line "item" to "mapItem". Try one of these :
<element maxOccurs="unbounded" minOccurs="0" name="mapItem" type="apachesoap:mapItem"/>
or
<element maxOccurs="unbounded" minOccurs="0" name="key" type="apachesoap:mapItem"/>
or
<element maxOccurs="unbounded" minOccurs="0" name="value" type="apachesoap:mapItem"/>
So it very late to help you but I recently was running into the same problem.
Firstly I am using Eclipse to create a web service. The problem for me was that the wsdd generated was using the 'document/literal(wrapped)' style. Changing that to 'RPC' fixed the issue. No more nulls.
So maybe if you change your encoding to RPC that might fix your issue too.
And this is why web services generated from code are almost never interoperable :)
One good way of working around this is to make the wsdl first, and define a nice clear little bit of XSD, that should map nicely into both .Net and java. An alternative is something other than axis 1.4 (yech, the pain) for the server if you have any control over that.
Finally, try massaging the signatures in the java code, try replacing List with MapItem[], or vice versa, make sure you don't have Map anywhere in a return object or a parameter.
Reviewing your generated wsdl again, I'd say this is probably because of the xsd:anyType for the key/value part of the mapItem.
I think that's what is generated by axis if you have a java Object in a parameter. Trust me, you don't want that. Make it a string, or a complex type, or an Integer, but an Object can only imply open ended xml (xsd:anyType) and not many clients no how to parse that.
I faced that, and I had to change WSDL file so:
<wsdlsoap:body use="encoded" ...
to
<wsdlsoap:body use="literal" ...
Only to perform the proxy generation.
I faced same issue. My solution is to remove the Namespace in auto-generated function.
This is my function:
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.service-now.com/incident/getRecords", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlArrayAttribute("getRecordsResponse", Namespace = "")]
[return: System.Xml.Serialization.XmlArrayItemAttribute("getRecordsResult", Form = System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable = false)]
public getRecordsResponseGetRecordsResult[] getRecords([System.Xml.Serialization.XmlElementAttribute("getRecords", Namespace = "http://www.service-now.com/incident")] getRecords getRecords1)
{
object[] results = this.Invoke("getRecords", new object[] {
getRecords1});
return ((getRecordsResponseGetRecordsResult[])(results[0]));
}
I removed the Namespace in this line. Bacause when I test the web service via SoapUI, I realized that the response object has no namespace. But auto-generated code has namespace.
[return: System.Xml.Serialization.XmlArrayAttribute("getRecordsResponse", Namespace = "")]
SoapUI Response was as following:
<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">
<SOAP-ENV:Body>
<getRecordsResponse>
<getRecordsResult>
<active>0</active>
</getRecordsResult>
</getRecordsResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>