SoapUI not finding my web-service - java

So I've been struggling with web-services for a couple of days now, and It seemed that I finally had a breakthrough.
I followed this tutorial to the letter, and I have my web-service up and running. The only problem is, that I can't seem to test it via soapUI.
If I go to http://localhost:8084/soapwebservices It displays the data about my web-service, eg, the location of wsdl, and so on. Judging by that, the link is correct.
But when I try to send this request to it:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="soapwebservices.jdevelop.eu">
<soapenv:Header/>
<soapenv:Body>
<soap:calculateValues>
<value1>10</value1>
<value2>3.21</value2>
</soap:calculateValues>
</soapenv:Body>
</soapenv:Envelope>
I get a 404 error:
<head><title>Not Found (404)</title></head>
<body><h1>Not Found (404)</h1>
<b>Original request:</b> http://localhost:8084/soapwebservices<br><br>
<b>Not found request:</b> http://localhost:8084/soapwebservices</body>
Here is my WSDL:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns:ns1="soapwebservices.jdevelop.eu" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="http://schemas.xmlsoap.org/soap/encoding/" name="SOAPWebServices" targetNamespace="soapwebservices.jdevelop.eu">
<types>
<xsd:schema>
<xsd:import namespace="soapwebservices.jdevelop.eu" schemaLocation="webservices.xsd"/>
</xsd:schema>
</types>
<message name="calculateValues">
<part name="calculateValues" element="ns1:calculateValues"/>
</message>
<message name="calculateValuesResponse">
<part name="calculateValuesResponse" element="ns1:calculateValuesResponse"/>
</message>
<portType name="SOAPWebServices">
<operation name="getCalculateValues">
<input message="ns1:calculateValues"/>
<output message="ns1:calculateValuesResponse"/>
</operation>
</portType>
<binding name="SOAPWebServicesPortBinding" type="ns1:SOAPWebServices">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getCalculateValues">
<soap:operation soapAction="urn:http://blog.jdevelop.eu/services/getCalculateValues"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="SOAPService">
<port name="WebServices" binding="ns1:SOAPWebServicesPortBinding">
<soap:address location="http://blog.jdevelop.eu:80/services"/>
</port>
</service>
</definitions>
What could be the problem here?
I am using Netbeans 6.0.1, Apache Tomcat 6.0 and Java SDK 1.7
Thanks!

Couple of observations:
In your SOAP message, the operation name you are sending is calculateValues (<soap:calculateValues>) whereas the operation name mentioned in the WSDL is getCalculateValues (<operation name="getCalculateValues">). This may be the reason behind 404 error as calculateValues operation is not defined.
I assume that you are not posting the SOAP message at the service URL mentioned in the WSDL (<soap:address location="http://blog.jdevelop.eu:80/services"/>).

Check the namespce in your endpoint class and the schema , both should be same

Related

Webservice compatibility issue due to name attribute in wsdl

I'm trying to use a third-party java-based webservice from a .net application. The thing is I'm having compatibility issues regarding the given wsdl. When I try to include this wsdl in my VStudio project I'm getting this message:
Warning: 'name' attribute is invalid. The value 'envio:Foo_Envio" is invalid for data type' http://www.w3.org/2001/XMLSchema:NCName '- The':' character, hexadecimal value 0x3A, can not be used in a name . Line 17, position 20
I've read here that they shouldn't use a colon character in the name attribute, because as a NCName type it's only allowed to use a very short set of them. The thing is when I import this wsdl in a Eclipse web project I've no issues at all. Does any of you have any clue about what's happening in Eclipse that doesn't work in VS?
Thanks in advance.
The concerning wsdl code:
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns:Foo="transmision" xmlns:envio="envio.xsd" xmlns:recepcion="recepcion.xsd" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace="transmision">
<types>
<schema elementFormDefault="qualified" xmlns:Foo="transmision" xmlns:envio="transmision" xmlns:FooRecepcion="recepcion.xsd" xmlns="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="recepcion.xsd" schemaLocation="recepcion.xsd"/>
<xsd:import namespace="envio.xsd" schemaLocation="envio.xsd"/>
</schema>
</types>
<message name="Foo_Envio">
<part name="envio" element="envio:envio"/>
</message>
<message name="Foo_Recepcion">
<part name="recepcion" element="recepcion:confirmacionRecepcion"/>
</message>
<portType name="Foo">
<operation name="Foo">
<input name="envio:Foo_Envio" message="Foo:Foo_Envio"/>
<output name="envio:Foo_Recepcion" message="Foo:Foo_Recepcion"/>
</operation>
</portType>
<binding name="FooSoapBinding" type="Foo:Foo">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="Foo">
<input>
<wsdlsoap:body use="literal"/>
</input>
<output>
<wsdlsoap:body use="literal"/>
</output>
</operation>
</binding>
<service name="FooService">
<port name="Foo" binding="Foo:FooSoapBinding">
<wsdlsoap:address location="https://ws.whatever.com/iniinvoc/es.foo.Foos.ws.EnvioSOAP"/>
</port>
</service>
</definitions>
In the end we've contacted with the third-party and they've changed the name attribute, removing the ":" character.

Duplicated MTOM policy on Weblogic 12.1.3

I'm developing download service using MTOM on weblogic 12.1.3 using JAX-WS. After deploy my wsdl has added two "MTOM" policies:
<definitions targetNamespace="http://schemas.test.pl/Test/001/2015/12/001" name="TestMTOM">
<wsp:UsingPolicy wsu:Required="true"/>
<wsp1_2:Policy wsu:Id="Mtom.xml">
<ns0:OptimizedMimeSerialization/>
</wsp1_2:Policy>
<wsp:UsingPolicy wssutil:Required="true"/>
<wsp1_2:Policy wssutil:Id="Mtom.xml">
<ns1:OptimizedMimeSerialization/>
</wsp1_2:Policy>
<wsp:Policy wssutil:Id="TestMTOM_portBinding_MTOM_Policy-TestMTOM_portBinding_MTOM_Policy">
<ns2:OptimizedMimeSerialization wsp:Optional="true"/>
</wsp:Policy>
<types>
<xsd:schema>
<xsd:import namespace="http://schemas.test.pl/Test/199/2014/07/001" schemaLocation="http://localhost:7001/TestWebservice/TestMTOM?xsd=1"/>
</xsd:schema>
<xsd:schema>
<xsd:import namespace="http://schemas.test.pl/Test/301/2015/12/001" schemaLocation="http://localhost:7001/TestWebservice/TestMTOM?xsd=2"/>
</xsd:schema>
<xsd:schema>
<xsd:import namespace="http://schemas.test.pl/Test/302/2015/12/001" schemaLocation="http://localhost:7001/TestWebservice/TestMTOM?xsd=3"/>
</xsd:schema>
</types>
<message name="ReadPrintFile">
<part name="requestBody" element="ns3:Document"/>
</message>
<message name="ReadPrintFileResponse">
<part name="responseBody" element="ns4:Document"/>
</message>
<message name="FaultMessage">
<part name="fault" element="ns5:Document"/>
</message>
<portType name="TestMTOM_portType">
<operation name="ReadPrintFile">
<input wsam:Action="http://schemas.test.pl/Test/TestMTOM/ReadPrintFile" message="tns:ReadPrintFile"/>
<output wsam:Action="http://schemas.test.pl/Test/001/2015/12/001/TestMTOM_portType/ReadPrintFileResponse" message="tns:ReadPrintFileResponse"/>
<fault message="tns:FaultMessage" name="FaultMessage" wsam:Action="http://schemas.test.pl/Test/001/2015/12/001/TestMTOM_portType/ReadPrintFile/Fault/FaultMessage"/>
</operation>
</portType>
<binding name="TestMTOM_portBinding" type="tns:TestMTOM_portType">
<wsp:PolicyReference URI="#Mtom.xml"/>
<wsp:PolicyReference URI="#TestMTOM_portBinding_MTOM_Policy-TestMTOM_portBinding_MTOM_Policy"/>
<wsp:PolicyReference URI="#Mtom.xml"/>
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="ReadPrintFile">
<soap:operation soapAction="http://schemas.test.pl/Test/TestMTOM/ReadPrintFile"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
<fault name="FaultMessage">
<soap:fault name="FaultMessage" use="literal"/>
</fault>
</operation>
</binding>
<service name="TestMTOM">
<port name="TestMTOM_port" binding="tns:TestMTOM_portBinding">
<soap:address location="http://localhost:7001/TestWebservice/TestMTOM"/>
</port>
</service>
Trying to connect to such deployed webservice is giving my error:
com.sun.xml.internal.ws.policy.PolicyException: WSP1020: Found two policies in one document with the same id: "Mtom.xml".
at com.sun.xml.internal.ws.policy.jaxws.SafePolicyReader$PolicyRecord.setUri(SafePolicyReader.java:113)
at com.sun.xml.internal.ws.policy.jaxws.SafePolicyReader.readPolicyElement(SafePolicyReader.java:272)
at com.sun.xml.internal.ws.policy.jaxws.PolicyWSDLParserExtension.definitionsElements(PolicyWSDLParserExtension.java:413)
at com.sun.xml.internal.ws.wsdl.parser.DelegatingParserExtension.definitionsElements(DelegatingParserExtension.java:80)
at com.sun.xml.internal.ws.wsdl.parser.FoolProofParserExtension.definitionsElements(FoolProofParserExtension.java:85)
at com.sun.xml.internal.ws.wsdl.parser.WSDLParserExtensionFacade.definitionsElements(WSDLParserExtensionFacade.java:123)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parseWSDL(RuntimeWSDLParser.java:464)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:234)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:194)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:163)
at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:348)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:306)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:215)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:196)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:192)
at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:104)
at javax.xml.ws.Service.<init>(Service.java:77)
at javax.xml.ws.Service.create(Service.java:707)
at com.test.ws.mtom.TestMTOMClient.main(TestMTOMClient.java:57)
Any idea woud be apreciated.
Service implementation is annotated like this:
#javax.xml.ws.soap.MTOM
#javax.jws.WebService(
serviceName = "TestMTOM",
portName = "TestMTOM_port",
targetNamespace = "http://schemas.test.pl/test/001/2015/12/001",
wsdlLocation = "file:/c:/TestWebservice/wsdl/TestMTOM.soap12/TestMTOM.wsdl",
endpointInterface = "pl.test.schemas.smw2._001._2015._12._001.TestMTOMPortType")
public class TestMTOMPortTypeImpl implements TestMTOMPortType {
}
and client is getting error while trying:
URL url = new URL("http://localhost:7001/TestWebservice/TestMTOM?WSDL");
QName qname = new QName("http://schemas.test.pl/test/001/2015/12/001", "TestMTOM");
Service service = TestMTOM.create(url, qname);
I have found a solution.
I prepared webservices.xml with the definition of my web service (although it wasn't needed) and put it in WEB-INF directory.
Deploying with such a file solved the problem.
Now deployed wsdl has only one MTOM policy :-)
In my case, removing the wsdlLocation attribute on the #javax.jws.WebService helped

SOAP Server in JAVA <-> SOAP Client in C#

I have a problem with a SOAP Server written in JAVA, the project is running as a windows service and not as a webserver (e.g. GLASSFISH).
So the problem is, everytime I make a request from a C# .NET client, the JAVA SOAP server is not able to parse the request. The called function gets a NULL value as input parameter.
The communictaion with JAVA clients, SoapUI, aso. works perfectly but the .NET (C#) clients are sending maleformed requests I think. Because the project is already existing and installed a lot of times, I can't develope it in C#.
I've read a lot of threads with similar problems, but I couldn't find any solution for my case.
I just wrote some simple test cases to show you the problem in a short way.
JAVA Code:
main.java
//...
Endpoint endpoint = Endpoint.create(new WS());
endpoint.publish("http://0.0.0.0:8081/test");
//...
WS.java
//...
#WebService(serviceName = "WS")
#SOAPBinding(style = SOAPBinding.Style.RPC)
public class WS {
#WebMethod(operationName = "echo")
public String echo(#WebParam(name = "val") String val) {
return val;
}
}
The WSDL:
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://webj/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://webj/" name="WS">
<types/>
<message name="echo">
<part name="val" type="xsd:string"/>
</message>
<message name="echoResponse">
<part name="return" type="xsd:string"/>
</message>
<portType name="WS">
<operation name="echo">
<input wsam:Action="http://webj/WS/echoRequest" message="tns:echo"/>
<output wsam:Action="http://webj/WS/echoResponse" message="tns:echoResponse"/>
</operation>
</portType>
<binding name="WSPortBinding" type="tns:WS">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
<operation name="echo">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" namespace="http://webj/"/>
</input>
<output>
<soap:body use="literal" namespace="http://webj/"/>
</output>
</operation>
</binding>
<service name="WS">
<port name="WSPort" binding="tns:WSPortBinding">
<soap:address location="http://xxx:8081/test"/>
</port>
</service>
C# Request
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<s:Body>
<echo xmlns="http://webj/">
<val xmlns="http://webj/">TEST</val>
</echo>
</s:Body>
</s:Envelope>
JAVA Request
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:std="http://webj/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<std:echo>
<val>TEST</val>
</std:echo>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
The problem seems to be the namespave of the parameter "val":
<echo xmlns="http://webj/">
<val xmlns="http://webj/">TEST</val>
</echo>
I've already tested this case in JAVA by adding a namespace to the parameter "val" manually and got the same problem. In C# I've tried with generated WebReferences and ServiceReferences.
(e.g. ServiceReference)
TestService.WSClient proxy = new TestService.WSClient();
String results = proxy.echo("TEST");
Can someone tell me how I can get the JAVA server compatible for .NET requests please?
Thanks for help!
Are you using Java JDK 1.8?
Because I don't think C# .NET is sending the namespace for the parameter, but it's sending an empty namespace like this:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<s:Body>
<echo xmlns="http://webj/">
<val xmlns="">TEST</val>
</echo>
</s:Body>
</s:Envelope>
Java JDK 1.8 contains a JAX-WS version with a bug. The empty namespaces of the requests of your C# client will be parsed completely wrong, just like your C# example above.
Try using the newsest version of >JAX-WS<.
>Here< you can find the description how to implement the libs.
As I see You have problem in namespaces, So when java parses it, finds no value and that's why you get null in Object values. Try to get the same XML structures from C#

WSDL got from a web service different from WSDL used to produce the web service

I have written a web service in a top down way : I wrote de WSDL first, then I used the wsimport tool to produce the WS interface and the proxies, and finally I wrote the WS implementation.
Now, my WS is deployed on a Tomee 1.6 server, and when I invoke it with a ?wsdl parameter, I get a WSDL wich is different from the one I wrote first. In my first WSDL the service name was "ImmoService", whereas in the WSDL I get when invoking the deployed web service, it is "ImmoServiceService".
I first thought it was a bug in Tomee, so I deployed the WS on Glassfish. But I got the same result. It seems that I have missed something. The name of the service in the WSDL produced by the WS should not be the same as the name of the service in the WSDL from which the WS was produced ?
Here is the WSDL I wrote first :
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:rp="http://ws.csf.fr/ImmoService"
targetNamespace="http://ws.csf.fr/ImmoService">
<types>
...
</types>
<!-- =========================================================================
Messages
========================================================================= -->
<message name="imprimerDocumentsSoapIn">
<part name="parameters" element="rp:imprimerDocuments"/>
</message>
<message name="imprimerDocumentsSoapOut">
<part name="parameters" element="rp:imprimerDocumentsResponse"/>
</message>
<!-- =========================================================================
PortType
========================================================================= -->
<portType name="ImmoServiceSoap">
<operation name="imprimerDocuments">
<input message="rp:imprimerDocumentsSoapIn"/>
<output message="rp:imprimerDocumentsSoapOut"/>
</operation>
</portType>
<!-- =========================================================================
Binding
========================================================================= -->
<binding name="ImmoServiceSoap" type="rp:ImmoServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="imprimerDocuments">
...
</operation>
</binding>
<!-- =========================================================================
Service
========================================================================= -->
<service name="ImmoService">
<port name="ImmoServiceSoap" binding="rp:ImmoServiceSoap">
<soap:address location="http://serveur:0/ImmoService/webservices/ImmoService"/>
</port>
</service>
</definitions>
Here is the one I get when invoking my WS under Tomee with the ?wsdl parameter
<?xml version='1.0' encoding='UTF-8'?>
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://ws.immoservice.csf.fr/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns2="http://schemas.xmlsoap.org/soap/http" xmlns:ns1="http://ws.csf.fr/ImmoService" name="ImmoServiceService" targetNamespace="http://ws.immoservice.csf.fr/">
<wsdl:import location="http://vir-ws-int.csf.asso.fr:8080/ImmoService/webservices/ImmoService?wsdl=ImmoServiceSoap.wsdl" namespace="http://ws.csf.fr/ImmoService">
</wsdl:import>
<wsdl:binding name="ImmoServiceServiceSoapBinding" type="ns1:ImmoServiceSoap">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="imprimerDocuments">
<soap:operation soapAction="http://csf.fr/ImmoService/imprimerDocuments" style="document"/>
<wsdl:input name="imprimerDocuments">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="imprimerDocumentsResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ImmoServiceService">
<wsdl:port binding="tns:ImmoServiceServiceSoapBinding" name="ImmoServicePort">
<soap:address location="http://vir-ws-int.csf.asso.fr:8080/ImmoService/webservices/ImmoService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Here is the WSDL I get when I invoke my WS under Glassfish :
<?xml version='1.0' encoding='UTF-8'?>
<!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.3 (tags/2.3-7528; 2013-04-29T19:34:10+0000) JAXWS-RI/2.2.8 JAXWS/2.2 svn-revision#unknown. -->
<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.3 (tags/2.3-7528; 2013-04-29T19:34:10+0000) JAXWS-RI/2.2.8 JAXWS/2.2 svn-revision#unknown. -->
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ws.immoservice.csf.fr/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://ws.immoservice.csf.fr/" name="ImmoServiceService">
<import namespace="http://ws.csf.fr/ImmoService" location="http://localhost:8081/ImmoServiceService/ImmoService?wsdl=1"/>
<binding xmlns:ns1="http://ws.csf.fr/ImmoService" name="ImmoServicePortBinding" type="ns1:ImmoServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="imprimerDocuments">
<soap:operation soapAction="http://csf.fr/ImmoService/imprimerDocuments"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="ImmoServiceService">
<port name="ImmoServicePort" binding="tns:ImmoServicePortBinding">
<soap:address location="http://localhost:8081/ImmoServiceService/ImmoService"/>
</port>
</service>
</definitions>
This is the normal behavior of Java SOAP Frameworks (Metro, CXF). They always create a different WSDL even if you wrote a WSDL by hand, generated Code using wsimport and then fetch the generated WSDL using ?wsdl. Some frameworks allow you to provide your own WSDL when exposing the Service (see http://cxf.apache.org/docs/jax-ws-configuration.html Param wsdlLocation)
If you have a self-written WSDL, use it to generate Clients and Services using your WSDL. Do not use the generated one (That's my experience). You can reference the generated WSDL for having an always valid Endpoint but not for more.

call third party web service using apache camel

I am new to camel
I am trying to call webservice using camel java dsl
from("cxf://http://darshan:8080/sampleWebService/SampleTestServicePort?wsdlURL=http://darshan:8080/sampleWebService/SampleTestServicePort?wsdl&serviceName={http://ws.test.com/}SampleTestServiceService&portName={http://ws.test.com/}SampleTestServicePort&dataFormat=MESSAGE")
following is my wsdl file:
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ws.test.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://ws.test.com/" name="SampleTestServiceService">
<types>
<xsd:schema>
<xsd:import namespace="http://ws.test.com/" schemaLocation="http://darshan:808O/sampleWebService/SampleTestServicePort?xsd=1"></xsd:import>
</xsd:schema>
</types>
<message name="sayHello">
<part name="parameters" element="tns:sayHello"></part>
</message>
<message name="sayHelloResponse">
<part name="parameters" element="tns:sayHelloResponse"></part>
</message>
<portType name="SampleTestServiceDelegate">
<operation name="sayHello">
<input message="tns:sayHello"></input>
<output message="tns:sayHelloResponse"></output>
</operation>
</portType>
<binding name="SampleTestServicePortBinding" type="tns:SampleTestServiceDelegate">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"></soap:binding>
<operation name="sayHello">
<soap:operation soapAction=""></soap:operation>
<input>
<soap:body use="literal"></soap:body>
</input>
<output>
<soap:body use="literal"></soap:body>
</output>
</operation>
</binding>
<service name="SampleTestServiceService">
<port name="SampleTestServicePort" binding="tns:SampleTestServicePortBinding">
<soap:address location="http://darshan:808O/sampleWebService/SampleTestServicePort"></soap:address>
</port>
</service>
</definitions>
That gives no error but also output is nothing.
Please suggest me what is wrong in my code.
Thanks in advance
When you use the Apache CXF Component as a from() what you are doing is you are hosting the webservice instead of accessing a third-party one.
To access a third-party service you need to use the to() form of the component. You need to do something like this:
<route>
<from uri="file:./myFileRequest?delay=1000&include=myRequest.xml">
<to uri="cxf://http://darshan:8080/sampleWebService/SampleTestServicePort?wsdlURL=http://darshan:8080/sampleWebService/SampleTestServicePort?wsdl&serviceName={http://ws.test.com/}SampleTestServiceService&portName={http://ws.test.com/}SampleTestServicePort&dataFormat=MESSAGE" />
...
</route>
Is this what you are looking for?
Define the cxf bean as below in the camel context
<cxf:cxfEndpoint
address="Service ENDPOINT"
endpointName="give wsdl:port#name here from wsdl"
id="any id" loggingFeatureEnabled="true"
serviceClass="your service class - it will be inside the stubs generated from WSDL"
serviceName="Service Name"
wsdlURL="WSDL path" xmlns:ws="namespace">
<cxf:properties>
<entry key="dataFormat" value="PAYLOAD"/>
</cxf:properties>
</cxf:cxfEndpoint>
then write the following in your route:
<to id="_to1" uri="cxf:bean:id Of the cxfEndpoint bean"/>

Categories