web services how to get the wsdl from the url web service - java

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

Related

Calling web service from Java "The message with Action '' cannot be processed at the receiver"

I'm newbie with web services and java, so I have some issues to connect my application with an external Web Service. I get all the time this exception
The message with Action '' cannot be processed at the receiver
Maybe my assumptions are wrong, but I think the action is defined inside the SOAP payload. Here is the WSDL:
<?xml version='1.0'?>
<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.tempuri.org/wsdl/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.tempuri.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/">
<types />
<message name="BINICIARREPORTRequest">
<part name="EAUSUARIO" type="xsd:string" />
<part name="EAMODULO" type="xsd:string" />
<part name="EANOMREPOR" type="xsd:string" />
<part name="EAPARAMREPOR" type="xsd:string" />
<part name="EANOMPANTA" type="xsd:string" />
</message>
<message name="BINICIARREPORTResponse">
<part name="RESULT" type="xsd:boolean" />
</message>
<portType name="PWS_LANZA_REPOR_PORT_1">
<operation name="BINICIARREPORT">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
<input message="tns:BINICIARREPORTRequest" />
<output message="tns:BINICIARREPORTResponse" />
</operation>
</portType>
<binding name="PWS_LANZA_REPOR_PORT_1Soap" type="tns:PWS_LANZA_REPOR_PORT_1">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" />
<operation name="BINICIARREPORT">
<soap:operation soapAction="http://www.tempuri.org/wsdl/BINICIARREPORTRequest" style="rpc" />
<input name="BINICIARREPORTRequest">
<soap:body use="encoded" namespace="http://www.tempuri.org/wsdl/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output name="BINICIARREPORTResponse">
<soap:body use="encoded" namespace="http://www.tempuri.org/wsdl/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
</binding>
<service name="PWS_LANZA_REPOR">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
<port name="PWS_LANZA_REPOR_PORT_1Port" binding="tns:PWS_LANZA_REPOR_PORT_1Soap">
<soap:address location="" />
</port>
</service>
</definitions>
Here is the code I'm using:
final String endpointUrl = this.configuracion
.getConfigJNDI(WS_MECANIZACION_JNDI);
final QName serviceName = new QName(null,
"PWS_LANZA_REPOR");
final QName portName = new QName(null, "PWS_LANZA_REPOR_PORT_1Port");
final javax.xml.ws.Service service = javax.xml.ws.Service
.create(serviceName);
service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING,
endpointUrl);
final Dispatch<SOAPMessage> dispatch = service.createDispatch(
portName, SOAPMessage.class,
javax.xml.ws.Service.Mode.MESSAGE);
final SOAPMessage response = dispatch.invoke(mensajeSOAP);
If I use SoapUI to check this out, everything works fine (the message is OK as well as the endpointURL), but no success whatsoever from the java application.
This is the soap message I'm sending:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="s" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<wsdl:BINICIARREPORT xmlns:wsdl="cosa">
<EAUSUARIO>CD</EAUSUARIO>
<EAMODULO>PR</EAMODULO>
<EANOMREPOR>PRR14</EANOMREPOR>
<EAPARAMREPOR/>
<EANOMPANTA/>
</wsdl:BINICIARREPORT>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I don't know whether this is important, but the url I was given has no "?wsdl" at then end:
http://prueba/prueba/Pws_Lanza_Rep1.svc
Any clues?
I haven't figured it out yet, but following the steps here everything worked fine!
I have used the same xml and the same parameters, so it still remains a mistery to me why the previous code didn't work.

JAX-WS null arguments

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

SOAP Encoding is not supported

I have WSDL url like with below format and that seems is correct. After using wsimport in terminal for parse that I get an error:
Run from terminal:
tux-world#alachiq:~/Desktop/Project/java > wsimport -keep -s wsdl/ example.com/wsdl/wsdl.php?wsdl
parsing WSDL...
[ERROR] "Use of SOAP Encoding is not supported.
SOAP extension element on line 59 in example.com/wsdl/wsdl.php?wsdl has use="encoded" "
Failed to parse the WSDL.
WSDL for Parse:
<?xml version="1.0" encoding="ISO-8859-1"?>
<definitions 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:tns="urn:tsmswsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="urn:tsmswsdl">
<types>
<xsd:schema targetNamespace="urn:tsmswsdl"
>
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
<xsd:complexType name="outGetMessages">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="xsd:string[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>
</types>
<message name="GetMessagesRequest">
<part name="user" type="xsd:string" />
<part name="pass" type="xsd:string" />
<part name="idend" type="xsd:int" />
<part name="count_request" type="xsd:int" /></message>
<message name="GetMessagesResponse">
<part name="return" type="tns:outGetMessages" /></message>
<message name="login_checkRequest">
<part name="user" type="xsd:string" />
<part name="pass" type="xsd:string" /></message>
<message name="login_checkResponse">
<part name="return" type="tns:outGetMessages" /></message>
<message name="send_smsRequest">
<part name="user" type="xsd:string" />
<part name="pass" type="xsd:string" />
<part name="sms_number" type="xsd:string" />
<part name="mobile" type="xsd:string" />
<part name="msg" type="xsd:string" />
<part name="send_date" type="xsd:string" /></message>
<message name="send_smsResponse">
<part name="return" type="tns:outGetMessages" /></message>
<portType name="tsmswsdlPortType">
<operation name="GetMessages">
<documentation>Get specific user info</documentation>
<input message="tns:GetMessagesRequest"/>
<output message="tns:GetMessagesResponse"/>
</operation>
<operation name="login_check">
<documentation>Get specific user info</documentation>
<input message="tns:login_checkRequest"/>
<output message="tns:login_checkResponse"/>
</operation>
<operation name="send_sms">
<documentation>Get specific user info</documentation>
<input message="tns:send_smsRequest"/>
<output message="tns:send_smsResponse"/>
</operation>
</portType>
<binding name="tsmswsdlBinding" type="tns:tsmswsdlPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="GetMessages">
<soap:operation soapAction="urn:tsmswsdl#GetMessages" style="rpc"/>
<input><soap:body use="encoded" namespace="urn:tsmswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
<output><soap:body use="encoded" namespace="urn:tsmswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
</operation>
<operation name="login_check">
<soap:operation soapAction="urn:tsmswsdl#login_check" style="rpc"/>
<input><soap:body use="encoded" namespace="urn:tsmswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
<output><soap:body use="encoded" namespace="urn:tsmswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
</operation>
<operation name="send_sms">
<soap:operation soapAction="urn:tsmswsdl#send_sms" style="rpc"/>
<input><soap:body use="encoded" namespace="urn:tsmswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
<output><soap:body use="encoded" namespace="urn:tsmswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
</operation>
</binding>
<service name="tsmswsdl">
<port name="tsmswsdlPort" binding="tns:tsmswsdlBinding">
<soap:address location="example.com/wsdl/wsdl.php"/>
</port>
</service>
</definitions>
To remove the ambiguity over whether this question has an answer or not, I'm posting the answer from the comments of #Roman Vottner:
Version 2 of JAX-WS does not support rpc/encoded. If you are in control of the web service try changing rpc/encoded to document/literal.
Suggested readings:
link 1
link 2
link 3
link 4
link 5

WSDL generate method with no parameters

I try to generate webservice using WSDL file. There is one method with no input parameter. I did it the following way:
...
<types>
<xsd:schema targetNamespace="http://api.registration.company.com"
xmlns:base="http://base.api.registration.company.com">
...
<xsd:element name="RemoveURLRequest">
<xsd:complexType>
<xsd:sequence />
</xsd:complexType>
</xsd:element>
<xsd:element name="RemoveURLResponse" type="xsd:boolean" />
</xsd:schema>
</types>
...
<message name="RemoveURLRequest">
<part name="RemoveURLRequest" element="tns:RemoveURLRequest" />
</message>
<message name="RemoveURLResponse">
<part name="RemoveURLResponse" element="tns:RemoveURLResponse" />
</message>
...
<portType name="RegistrationService">
...
<operation name="RemoveURL">
<input message="tns:RemoveURLRequest" />
<output message="tns:RemoveURLResponse" />
</operation>
...
</portType>
<binding name="RegistrationServiceSOAP" type="tns:RegistrationService">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
...
<operation name="RemoveURL">
<soap:operation soapAction=
"http://api.registration.company.com/web/services/RegistrationService/RemoveURL"
style="document" />
<input>
<soap:body parts="RemoveURLRequest" use="literal" />
</input>
<output>
<soap:body parts="RemoveURLResponse" use="literal" />
</output>
</operation>
</binding>
<service name="RegistrationService">
<port name="RegistrationServiceSOAP" binding="tns:RegistrationServiceSOAP">
<soap:address location=
"http://api.registration.company.com/web/services/RegistrationService" />
</port>
</service>
According to this WSDL I expect method to be generated like this:
public boolean removeURL();
But I'm getting this:
public boolean removeURL(RemoveURLRequest removeURLRequest);
Where RemoveURLRequest is an empty class:
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "")
#XmlRootElement(name = "RemoveURLRequest")
public class RemoveURLRequest {
}
What am I doing wrong?
try some thing like this
<message name="RemoveURLRequest">
</message>
without using the part element.
You must create an empty complex Type and use it as parameter. see the following post which is a similar question : WSDL Type for getter without parameter.
Jax-WS usually generate such code when the message/part/schema types ends with the keyword "Request". Give it a try without by removing the "Request" part of the name. This should give you the expected results

axis 2 web service : null parameters issue with http binding

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.

Categories