My webservice defines a WS Addressing policy in its WSDL with
<wsp:Policy wss:Id="WSAddressing_policy"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata">
<wsam:Addressing>
<wsp:policy/>
</wsam:Addressing>
</wsp:Policy>
... and
<wsdl:binding name="OutboundBinding" type="tns:OutboundPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsp:PolicyReference URI="#WSAddressing_policy"/>
<!-- Verify Availability -->
<wsdl:operation name="VerifyAvailability">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="VerifyAvailabilityRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="VerifyAvailabilityResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
I use CXFs automatic interceptors for policies:
<cxf:bus>
<cxf:features>
<p:policies ignoreUnknownAssertions="true"/>
<cxf:logging/>
</cxf:features>
</cxf:bus>
Now I'm unable to create a valid request to this webservice with SOAP UI - I always get the following response, regardless which WS-A settings I try:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode xmlns:ns1="http://www.w3.org/2005/08/addressing">ns1:MessageAddressingHeaderRequired</faultcode>
<faultstring>A required header representing a Message Addressing Property is not present</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
What am I doing wrong?
Update
I'm also unable to create a valid request using a CXF Client itself. I managed to get it working if I change the WSDL from
<wsp:Policy wss:Id="WSAddressing_policy">
<wsam:Addressing>
<wsp:policy/>
</wsam:Addressing>
</wsp:Policy>
to
<wsp:Policy wss:Id="WSAddressing_policy">
<wsaw:UsingAddressing xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" wsp:Optional="false" />
</wsp:Policy>
It seems the addressing metadata namespace is currently the problem for CXF.
I filed a bugreport.
Using
xmlns:wsam="http://www.w3.org/2007/02/addressing/metadata"
instead of
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"
solves the problem.
Related
i have a webservice whose wsdl is follows:
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 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:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:i0="ns" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" name="TemperatureService" targetNamespace="http://tempuri.org/">
<wsdl:import namespace="ns" location="http://localhost:57205/TemperatureService.svc?wsdl=wsdl0"/>
<wsdl:types/>
<wsdl:binding name="BasicHttpBinding_ITemperatureService" type="i0:ITemperatureService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="SayHello">
<soap:operation soapAction="ns/ITemperatureService/SayHello" style="document"/>
<wsdl:input name="TempRequest">
<soap:header message="i0:TempRequest_Headers" part="Id" use="literal"/>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="TempResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="TemperatureService">
<wsdl:port name="BasicHttpBinding_ITemperatureService" binding="tns:BasicHttpBinding_ITemperatureService">
<soap:address location="http://localhost:57205/TemperatureService.svc"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
i am trying to consume the service with coldfusion code as follows:
<cfscript>
wsURL = "http://localhost:57205/TemperatureService.svc?wsdl";
ws = CreateObject("webservice", wsURL);
writeDump(ws);
addSOAPRequestHeader(ws, "ns", "Id", "22363");
response = ws.SayHello("John");
writeDump(response);
</cfscript>
but when i browse the cfm page i get the following error:
i solved the issue with the combination of addSOAPRequestHeader method and structNew as i have to pass values both in header and body.
<cfscript>
wsURL = "http://localhost:57205/TemperatureService.svc?wsdl";
ws = CreateObject("webservice", wsURL);
addSOAPRequestHeader(ws, "ns", "Id", "22363");
tempRequest = structNew();
tempRequest.Name = "John";
response = ws.SayHello(tempRequest);
</cfscript>
Problem:
I have a SOAP service with the following simplified WSDL:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://new.webservice.namespace" targetNamespace="http://new.webservice.namespace">
<wsdl:types>
<xs:schema targetNamespace="http://new.webservice.namespace" elementFormDefault="qualified"/>
</wsdl:types>
<wsdl:message name="NewMessageRequest">
<wsdl:part name="parameter" type="xs:string"/>
</wsdl:message>
<wsdl:message name="NewMessageResponse">
<wsdl:part name="result" type="xs:string"/>
<wsdl:part name="param2" type="xs:string"/>
</wsdl:message>
<wsdl:portType name="NewPortType">
<wsdl:operation name="NewOperation">
<wsdl:input message="tns:NewMessageRequest"/>
<wsdl:output message="tns:NewMessageResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="NewBinding" type="tns:NewPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="NewOperation">
<soap:operation soapAction="urn:#NewOperation"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="NewService">
<wsdl:port name="NewPort" binding="tns:NewBinding">
<soap:address location="No Target Adress"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Notice the output message has two parts.
When invoking the SOAP services with SoapUI, the services implemented with the gSOAP framework returns a response which does not comply with the WSDL:
This is the SoapUI request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:new="http://new.webservice.namespace">
<soapenv:Header/>
<soapenv:Body>
<new:NewOperation>
<parameter>Hello</parameter>
</new:NewOperation>
</soapenv:Body>
</soapenv:Envelope>
This is the gSOAP WS response:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:new="http://new.webservice.namespace">
<soapenv:Header/>
<soapenv:Body>
<new:NewOperationResponse>
<result xsi:nil="true"/>
<param2>Hello World</param2>
</new:NewOperationResponse>
</soapenv:Body>
</soapenv:Envelope>
SoapUI complains with the following error:
line5: Element has xsi:nil attribute but is not nillable
Question:
How can I fix the WSDL so the message part is nullable?
It appears you may have set the SOAP_XML_NIL flag? This flag should not be set. See the gsoap documentation stating for SOAP_XML_NIL: output NULLs as xsi:nil.
I develop a code first SOAP web service with CXF, and this a WSDL which I get. Why is there a import on WSDL
the second line is the one of the interest:
I am guessing that maybe it has something to do with namespaces ? I wonder if publishing the code of the web service impl will help ?
<wsdl:import location="http://localhost:8080/abc/RaceCalc?wsdl=RaceCalc.wsdl" namespace="http://service.wrapper.ie/">
</wsdl:import>
WSDL generated from Web Service:
<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions name="RaceCalcImplService" targetNamespace="http://impl.service.wrapper.ie/" xmlns:ns1="http://service.wrapper.ie/" xmlns:ns2="http://cxf.apache.org/bindings/xformat" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://impl.service.wrapper.ie/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:import location="http://localhost:8080/abc/RaceCalc?wsdl=RaceCalc.wsdl" namespace="http://service.wrapper.ie/">
</wsdl:import>
<wsdl:binding name="RaceCalcImplServiceSoapBinding" type="ns1:RaceCalc">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="setRaceCalcHelper">
<soap:operation soapAction="" style="document" />
<wsdl:input name="setRaceCalcHelper">
<soap:body use="literal" />
</wsdl:input>
<wsdl:output name="setRaceCalcHelperResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="calculate">
<soap:operation soapAction="" style="document" />
<wsdl:input name="calculate">
<soap:body use="literal" />
</wsdl:input>
<wsdl:output name="calculateResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="RaceCalcImplService">
<wsdl:port binding="tns:RaceCalcImplServiceSoapBinding" name="RaceCalcImplPort">
<soap:address location="http://localhost:8080/abc/RaceCalc" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Because you have two different namespaces on your implementation: {http://service.wrapper.ie/} and {http://impl.service.wrapper.ie/}. You surely have the interface in package ie.wrapper.service and the implementation in ie.wrapper.service.impl. CXF is therefore assuming the namespace {http://service.wrapper.ie/} for the logical stuff (interface/portType) and the namespace {http://impl.service.wrapper.ie/} for the physical stuff (impl/service/binding). Adding the #WebService(targetNamespace = "http://whatever.you.want") annotation to both, interface and implementation should remove the (need of an) import in the WSDL.
I have created a client to access a WS using maven and CXF, following the tutorials here and here as well.
I have tested the web service a number of times using SoapUI and received the results. But when I call the same web service from my client, I always get an empty response. At web service side, I have observed that the response is properly sent, in case of SoapUI and my client application both.
this is what gets printed on console at client side:
WS init successful. Service class instantiated.
In servlet Calling service now
Action is -- JAX-WS RI 2.1.6 in JDK 6: Stub for http://172.18.40.131:8080/AccountWithCXF/services/AccountSearchActionPort
In servlet after Calling service. list is -> []
Can someone please help me?
Following is the WSDL:
<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions name="AccountSearchActionService" targetNamespace="http://webservice/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://webservice/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://webservice/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<import namespace="http://webservice/" schemaLocation="http://172.18.40.131:8080/AccountWithCXF/services/AccountSearchActionPort?xsd=accountsearchaction_schema1.xsd"/>
</schema>
</wsdl:types>
<wsdl:message name="getAccountsResponse">
<wsdl:part element="tns:getAccountsResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getAccounts">
<wsdl:part element="tns:getAccounts" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="AccountSearchAction">
<wsdl:operation name="getAccounts">
<wsdl:input message="tns:getAccounts" name="getAccounts">
</wsdl:input>
<wsdl:output message="tns:getAccountsResponse" name="getAccountsResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="AccountSearchActionServiceSoapBinding" type="tns:AccountSearchAction">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getAccounts">
<soap:operation soapAction="urn:GetAccounts" style="document"/>
<wsdl:input name="getAccounts">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getAccountsResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="AccountSearchActionService">
<wsdl:port binding="tns:AccountSearchActionServiceSoapBinding" name="AccountSearchActionPort">
<soap:address location="http://172.18.40.131:8080/AccountWithCXF/services/AccountSearchActionPort"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I am setting the web service stub in init() method of my servlet
public void init() throws ServletException {
super.init();
service = new AccountSearchActionService();
System.out.println("WS init successful. Service class instantiated.");
}
Code piece from Servlet that calls web service:
AccountSearchAction action = service.getAccountSearchActionPort();
System.out.println("Action is -- "+action);
List<Account> list = action.getAccounts(param);
System.out.println("In servlet after Calling service. list is -> "+list);
If i call this web service using SoapUI with search query 'express', following is the response I get:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:getAccountsResponse xmlns:ns2="http://webservice/">
<ns2:return>
<accountId>3067822</accountId>
<accountName>FBB EXPRESS INC.</accountName>
</ns2:return>
</ns2:getAccountsResponse>
</soap:Body>
</soap:Envelope>
The easiest way to debug this is to capture the request and response XML.
One way of doing that is to sent up the logging interceptor.
Another ways is to use tcpmon to capture request / response and response. tcpmon works like a proxy - set it up to listen on some port and then forward it to the original service host:port. Make the client send request to the tcpmon port.
I am currently trying to use a web service I developed within an Integration Services package. When I try to configure the web service task I keep getting an error message. I configured the HTTP connection, and successfully downloaded the WSDL file which overrides my local copy. After that, on the input tab, I try to select the only service available "MyService" and then get the following error message:
Item has already been added. Key in dictionary: 'anyType' Key being added: 'anyType'
Anyone knows what this means?
Thanks in advance!
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions name="MyService" targetNamespace="http://www.MyDomain.de/webservices" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://www.MyDomain.de/webservices" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex">
<wsdl:types>
<xsd:schema targetNamespace="http://www.MyDomain.de/webservices/Imports">
<xsd:import schemaLocation="http://localhost/MyDomainMyService/MyDomain.Billing.Infrastructure.Wcf.MyService.svc?xsd=xsd0" namespace="http://www.MyDomain.de/webservices" />
<xsd:import schemaLocation="http://localhost/MyDomainMyService/MyDomain.Billing.Infrastructure.Wcf.MyService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
</xsd:schema>
</wsdl:types>
<wsdl:message name="MyService_BookNewTransaction_InputMessage">
<wsdl:part name="parameters" element="tns:BookNewTransaction" />
</wsdl:message>
<wsdl:message name="MyService_BookNewTransaction_OutputMessage">
<wsdl:part name="parameters" element="tns:BookNewTransactionResponse" />
</wsdl:message>
<wsdl:portType name="MyService">
<wsdl:operation name="BookNewTransaction">
<wsdl:input wsaw:Action="http://www.MyDomain.de/webservices/MyService/BookNewTransaction" message="tns:MyService_BookNewTransaction_InputMessage" />
<wsdl:output wsaw:Action="http://www.MyDomain.de/webservices/MyService/BookNewTransactionResponse" message="tns:MyService_BookNewTransaction_OutputMessage" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="BasicHttpBinding_MyService" type="tns:MyService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="BookNewTransaction">
<soap:operation soapAction="http://www.MyDomain.de/webservices/MyService/BookNewTransaction" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="MyService">
<wsdl:port name="BasicHttpBinding_MyService" binding="tns:BasicHttpBinding_MyService">
<soap:address location="http://localhost/MyDomainMyService/MyDomain.Billing.Infrastructure.Wcf.MyService.svc" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Ok, I found a link describing my problem.
Check this:
http://sjbdeveloper.blogspot.com/2007/03/calling-wcf-web-service-from-ssis-web.html
This should solve the problem:
http://sjbdeveloper.blogspot.com/2007/03/fixing-wcf-ssis-web-service-task.html