SOAP Webservices - java

I have a wsdl containing SAOP Header and SOAP Body. I generated client with eclipse and APACHE CXF and sent request. But request is failing saying Header is missed or invalid.
<?xml version="1.0" encoding="UTF-8"?>
<types>
<xsd:schema>
<xsd:import
namespace="http://finservice.cl.com/Services/financier/Operational/Messages/Request"
schemaLocation="financierRequest.xsd"/>
<xsd:import
namespace="http://finservice.cl.com/Services/financier/Operational/Messages/Response"
schemaLocation="financierResponse6.xsd"/>
<xsd:import namespace="http://finservice.cl.com/Services/Faults"
schemaLocation="finserviceFaults.xsd"/>
<xsd:import namespace="http://www.cl.com/Services/SOAPHeaders"
schemaLocation="CLSoapHeaders.xsd"/>
<xsd:import
namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
schemaLocation="oasis-200401-wss-wssecurity-secext-1.0.xsd"/>
</xsd:schema>
</types>
<message name="WS-Security-SOAPHeader">
<part element="wssec:Security" name="Security"/>
</message>
<message name="CLSOAPHeader">
<part element="hdr_ns:RequestContextHeader" name="requestHeader"/>
<part element="hdr_ns:ProcessingNodesHeader" name="processingNodesHeader"/>
</message>
<message name="financierRequest">
<part element="req_ns:financierRequestElement" name="financierRequestElement"/>
</message>
<message name="financierResponse">
<part element="res_ns:financierResponseElement" name="financierResponseElement"/>
</message>
<message name="Fault_Exception">
<part element="fault_ns:Fault" name="fault"/>
</message>
<portType name="finServicePortType">
<operation name="getFinanciers">
<input message="tns:financierRequest"/>
<output message="tns:financierResponse"/>
<fault message="tns:Fault_Exception" name="Fault_Exception"/>
</operation>
</portType>
<binding name="finServiceBinding" type="tns:finServicePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getFinanciers">
<soap:operation soapAction=""/>
<input>
<soap:body parts="financierRequestElement" use="literal"/>
<soap:header message="tns:CLSOAPHeader" part="requestHeader" use="literal"/>
<!-- soap:header message="tns:CLSOAPHeader" part="processingNodesHeader" use="optional"/-->
<soap:header message="tns:WS-Security-SOAPHeader" part="Security" use="literal"/>
</input>
<output>
<soap:body use="literal"/>
<soap:header message="tns:CLSOAPHeader" part="processingNodesHeader" use="literal"/>
<soap:header message="tns:WS-Security-SOAPHeader" part="Security" use="literal"/>
</output>
<fault name="Fault_Exception">
<soap:fault name="Fault_Exception" use="literal"/>
</fault>
</operation>
</binding>
<service name="financierService_v4">
<port binding="tns:finServiceBinding" name="finServicePort">
<soap:address location="http://finservice.qtcorpCL.cl.com:20021/finservService"/>
</port>
</service>
Can any one guide me how to write client for this wsdl?
How to attach header for this.

Did you test this wsdl in soapui? https://www.soapui.org/
I would suggest to first see what is the request and response structure of this web than may be you can use same request structure in your eclipse client. Soapui is very easy to use.

To generate all the client artifacts, you would need to use wsimport and then read about SOAP clients... Simple JAX-WS client

Related

Change xmlns value from endpointInterface

I'm having a Java webservice which looks like:
#WebService(endpointInterface = "vas.WSIF")
public class WSImpl implements WSIF {
}
and an endpointInterface:
#WebService ()
#SOAPBinding(style = SOAPBinding.Style.RPC)
public abstract interface WSIF {
}
My request have to be:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:vas="http://vas/">
<soapenv:Header/>
<soapenv:Body>
<vas:sayhello>
<info>?</info>
</vas:sayhello>
</soapenv:Body>
</soapenv:Envelope>
How can I change xmlns:vas="http://vas/" in to another value like xmlns:vas="http://hellovas.com"?
I think it's just follow the package name right now.
<!--
Published by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e.
-->
<!--
Generated by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e.
-->
<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://vas/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://vas/" name="WSImplService">
<types>
<xsd:schema>
<xsd:import namespace="http://vas/" schemaLocation="http://localhost:8080/API?xsd=1"/>
</xsd:schema>
</types>
<message name="register">
<part name="msisdn" type="xsd:string"/>
<part name="packageCode" type="xsd:string"/>
<part name="username" type="xsd:string"/>
<part name="password" type="xsd:string"/>
<part name="channel" type="xsd:string"/>
<part name="info" type="xsd:string"/>
</message>
<message name="registerResponse">
<part name="return" type="tns:registerResponse"/>
</message>
<message name="unregister">
<part name="msisdn" type="xsd:string"/>
<part name="packageCode" type="xsd:string"/>
<part name="username" type="xsd:string"/>
<part name="password" type="xsd:string"/>
<part name="channel" type="xsd:string"/>
<part name="info" type="xsd:string"/>
</message>
<message name="unregisterResponse">
<part name="return" type="tns:unregisterResponse"/>
</message>
<message name="packagelist">
<part name="username" type="xsd:string"/>
<part name="password" type="xsd:string"/>
</message>
<message name="packagelistResponse">
<part name="return" type="tns:packagelistResponse"/>
</message>
<message name="checkstatus">
<part name="msisdn" type="xsd:string"/>
<part name="username" type="xsd:string"/>
<part name="password" type="xsd:string"/>
</message>
<message name="checkstatusResponse">
<part name="return" type="tns:checkstatusResponse"/>
</message>
<message name="decryptAES128">
<part name="input" type="xsd:string"/>
</message>
<message name="decryptAES128Response">
<part name="return" type="xsd:string"/>
</message>
<portType name="WSIF">
<operation name="register" parameterOrder="msisdn packageCode username password channel info">
<input wsam:Action="http://vas/WSIF/registerRequest" message="tns:register"/>
<output wsam:Action="http://vas/WSIF/registerResponse" message="tns:registerResponse"/>
</operation>
<operation name="unregister" parameterOrder="msisdn packageCode username password channel info">
<input wsam:Action="http://vas/WSIF/unregisterRequest" message="tns:unregister"/>
<output wsam:Action="http://vas/WSIF/unregisterResponse" message="tns:unregisterResponse"/>
</operation>
<operation name="packagelist" parameterOrder="username password">
<input wsam:Action="http://vas/WSIF/packagelistRequest" message="tns:packagelist"/>
<output wsam:Action="http://vas/WSIF/packagelistResponse" message="tns:packagelistResponse"/>
</operation>
<operation name="checkstatus" parameterOrder="msisdn username password">
<input wsam:Action="http://vas/WSIF/checkstatusRequest" message="tns:checkstatus"/>
<output wsam:Action="http://vas/WSIF/checkstatusResponse" message="tns:checkstatusResponse"/>
</operation>
<operation name="decryptAES128">
<input wsam:Action="http://vas/WSIF/decryptAES128Request" message="tns:decryptAES128"/>
<output wsam:Action="http://vas/WSIF/decryptAES128Response" message="tns:decryptAES128Response"/>
</operation>
</portType>
<binding name="WSImplPortBinding" type="tns:WSIF">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
<operation name="register">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" namespace="http://vas/"/>
</input>
<output>
<soap:body use="literal" namespace="http://vas/"/>
</output>
</operation>
<operation name="unregister">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" namespace="http://vas/"/>
</input>
<output>
<soap:body use="literal" namespace="http://vas/"/>
</output>
</operation>
<operation name="packagelist">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" namespace="http://vas/"/>
</input>
<output>
<soap:body use="literal" namespace="http://vas/"/>
</output>
</operation>
<operation name="checkstatus">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" namespace="http://vas/"/>
</input>
<output>
<soap:body use="literal" namespace="http://vas/"/>
</output>
</operation>
<operation name="decryptAES128">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" namespace="http://vas/"/>
</input>
<output>
<soap:body use="literal" namespace="http://vas/"/>
</output>
</operation>
</binding>
<service name="WSImplService">
<port name="WSImplPort" binding="tns:WSImplPortBinding">
<soap:address location="http://localhost:8080/API"/>
</port>
</service>
</definitions>

PHP: Error calling SOAP rpc webservice from Java - Worked before

I have a java program which calls methods in php (rpc) over SOAP.
Since a couple of days it does not work anylonger from my existing code.
On my dev machine I recently updated to php7.0, but on the remote server there is still php5.x running. It neither works with localhost, nor with the remote server. Both machines are running Ubuntu (dev 16.04, remote 14.04)
I always get the following error:
[SOAPException: faultCode=SOAP-ENV:Client; msg=Parsing error, response was:
The processing instruction target matching "[xX][mM][lL]" is not allowed.; targetException=org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 6;
The processing instruction target matching "[xX][mM][lL]" is not allowed.]
I tested with SOAP UI, and it works, no error.
I even tested with apache axis2, but fails, too.
the problem is that the response from the php script seems to be invalid.
I looked at the encoding etc, checked if there is a new line or whatever. But I have no clue what the problem could be.
Sample soap call which works in Soap UI:
<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:searchQuery xmlns:ns1="http://localhost/Server.php" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<query xsi:type="xsd:string">oil</query>
</ns1:searchQuery>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Response: When I click on validate in Soap UI, it tells me that the xml declration is not well formed. But I have no idea how to change it.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://localhost/Server.php" 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/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body><ns1:searchQueryResponse><return xsi:type="xsd:string">{
"prefixes": ..... }
</return></ns1:searchQueryResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
The php Code I use to initialize the soap server:
try {
ini_set ( "soap.wsdl_cache_enabled", "0" );
$server = new SOAPServer ( 'Server.wsdl' );
$server->setClass ( 'Webdienst' );
$server->handle ();
}
catch ( SOAPFault $f ) {
echo $f->getMessage ();
}
My wsdl file:
<?xml version="1.0"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://localhost/Server.php" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="Webdienst" targetNamespace="http://localhost/Server.php">
<types>
<xsd:schema targetNamespace="http://localhost/Server.php">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
</xsd:schema>
</types>
<portType name="WebdienstPort">
<operation name="createRecord">
<documentation>Create a new record</documentation>
<input message="tns:createRecordIn"/>
<output message="tns:createRecordOut"/>
</operation>
<operation name="searchQuery">
<documentation>Search for the String</documentation>
<input message="tns:searchQueryIn"/>
<output message="tns:searchQueryOut"/>
</operation>
</portType>
<binding name="WebdienstBinding" type="tns:WebdienstPort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="createRecord">
<soap:operation soapAction="http://localhost/Server.php#createRecord"/>
<input>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost/Server.php"/>
</input>
<output>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost/Server.php"/>
</output>
</operation>
<operation name="searchQuery">
<soap:operation soapAction="http://localhost/Server.php#searchQuery"/>
<input>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost/Server.php"/>
</input>
<output>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost/Server.php"/>
</output>
</operation>
</binding>
<service name="WebdienstService">
<port name="WebdienstPort" binding="tns:WebdienstBinding">
<soap:address location="http://localhost/Server.php"/>
</port>
</service>
<message name="createRecordIn">
<part name="recordURI" type="xsd:anyType"/>
<part name="documentURI" type="xsd:anyType"/>
<part name="content" type="xsd:anyType"/>
<part name="fileName" type="xsd:anyType"/>
<part name="mimeType" type="xsd:anyType"/>
<part name="creationDate" type="xsd:anyType"/>
<part name="datasetURI" type="xsd:anyType"/>
<part name="translatedContent" type="xsd:anyType"/>
<part name="alchemyTopics" type="xsd:anyType"/>
<part name="summary" type="xsd:anyType"/>
<part name="author" type="xsd:anyType"/>
</message>
<message name="createRecordOut">
<part name="return" type="xsd:string"/>
</message>
<message name="searchQueryIn">
<part name="query" type="xsd:anyType"/>
</message>
<message name="searchQueryOut">
<part name="return" type="xsd:string"/>
</message>
</definitions>
I found the solution after googling around.
The problem was that I had an include() declaration at top of my soap server class which included another php file. The other php file had an empty line after the ?> closing tag. I moved the closing tag directly after the last brace and now it works!

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

How to test a webservice / WSDL

I have generated this WSDL file...
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. -->
<definitions targetNamespace="http://math/" name="MathServicesService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://math/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<types>
<xsd:schema>
<xsd:import namespace="http://math/" schemaLocation="MathServicesService_schema1.xsd"/>
</xsd:schema>
</types>
<message name="addTwoInts">
<part name="parameters" element="tns:addTwoInts"/>
</message>
<message name="addTwoIntsResponse">
<part name="parameters" element="tns:addTwoIntsResponse"/>
</message>
<message name="multiplyTwoFloats">
<part name="parameters" element="tns:multiplyTwoFloats"/>
</message>
<message name="multiplyTwoFloatsResponse">
<part name="parameters" element="tns:multiplyTwoFloatsResponse"/>
</message>
<portType name="MathServices">
<operation name="addTwoInts">
<input message="tns:addTwoInts"/>
<output message="tns:addTwoIntsResponse"/>
</operation>
<operation name="multiplyTwoFloats">
<input message="tns:multiplyTwoFloats"/>
<output message="tns:multiplyTwoFloatsResponse"/>
</operation>
</portType>
<binding name="MathServicesPortBinding" type="tns:MathServices">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="addTwoInts">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="multiplyTwoFloats">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="MathServicesService">
<port name="MathServicesPort" binding="tns:MathServicesPortBinding">
<soap:address location="REPLACE_WITH_ACTUAL_URL"/>
</port>
</service>
</definitions>
from this class...
package math;
import javax.jws.WebService;
#WebService
public class MathServices {
public int addTwoInts(int int1, int int2){
return int1+int2;
}
public float multiplyTwoFloats(float float1, float float2){
return float1 * float2;
}
}
How can I test to see if this webservice is working properly using the WSDL? I don't understand how the functionality (int1+int2 and float1*float2) translates to the XML. All I see in the WSDL are what translate to method names and parameter names. I don't see where the math goes on. :/
That said, where do the parameters come from when using the webservice? How do you even use the webservice? Can I just use it through my browser?
For soap you can use SoapUI. See http://www.soapui.org/.
You can test WSDLs with SoapUI.

Categories