(1) The class I described below includes three strings and one entity.
(2) The text I sent as a call is as follows.
(3) But I'm making the mistake.
1:
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "", propOrder = {"tesisatKod", "islemGuid", "islemTutari", "islemTuru"})
#XmlRootElement(name = "secondStageRequest")
public class SecondStageRequest {
protected String tesisatKod;
protected String islemGuid;
// protected Date sorguSaatTarih;
protected String islemTutari;
protected IslemTuru islemTuru;
}
2:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xc="http://xml.cinigaz.com.tr">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" wsse:mustUnderstand="1">
<wsse:UsernameToken>
<wsse:Username>admin</wsse:Username>
<wsse:Password>pwd1234</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<xc:secondStageRequest>
<xc:tesisatKod>bbb</xc:tesisatKod>
<xc:islemGuid>bbb</xc:islemGuid>
<xc:islemTutari>bbb</xc:islemTutari>
<xc:islemTuru>
<xc:islemTuruId> 1</xc:islemTuruId>
<xc:islemTuruAdi> aaa</xc:islemTuruAdi>
</xc:islemTuru>
</xc:secondStageRequest>
</soapenv:Body>
</soapenv:Envelope>
3:
WARN 20148 --- [nio-9020-exec-2] s.w.s.s.e.i.PayloadValidatingInterceptor : XML validation error on request: cvc-type.3.1.2: Element 'xc:islemTuru' is a simple type, so it must have no element information item [children].
Related
I'm a project than I generate a wsdl client with apache cfx.
When I run my project in mi local machine with Windows it works perfectlly, but when I was to try in machine with SO Linux (Red hat) it didn't work.
My xml since Windows is:
<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
<env:Header>
<wsse:Security xmlns:wsse='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' xmlns:wsu='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'>
<wsse:UsernameToken wsu:Id='UsernameToken-3e963a94-b8fc-4876-ace8-b675f270d3a0'>
<wsse:Username>myusername</wsse:Username>
<wsse:Password Type='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'>mypass</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
<ns4:HeaderReq xmlns:ns4='http://www.something.com/ws/nss/general/Headers' xmlns:ns3='http://www.something.com/ws/nss/common/ExcepcionGeneral' xmlns:ns2='http://www.something.com/ws/iss/nameWebConsume' locale='es_MX' codIdioma='UTF-8'>
<Deploy>
***
</Deploy>
<Access>
***
</Access>
<Consumer>
***
</Consumer>
<RequestData>
***
</RequestData>
</ns4:HeaderReq>
</env:Header>
<env:Body>
<CheckSomething xmlns='http://www.something.com/ws/nss/nameWebConsume' xmlns:ns4='http://www.something.com/ws/nss/general/Headers' xmlns:ns3='http://www.something.com/ws/nss/common/ExcepcionGeneral' xmlns:ns2='http://www.something.com/ws/iss/nameWebConsume'>
<Folio>123456789</Folio>
</CheckSomething>
</env:Body>
</env:Envelope>
My xml since linux is:
<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
<soap:Header>
<wsse:Security xmlns:wsse='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' xmlns:wsu='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'>
<wsse:UsernameToken wsu:Id='UsernameToken-9d835b01-63d0-4d88-9d15-6c06b73531a2'>
<wsse:Username>myusername</wsse:Username>
<wsse:Password Type='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'>mypass</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
<ns2:HeaderReq xmlns:ns2='http://www.something.com/ws/nss/general/Headers' xmlns:ns3='http://www.something.com/ws/nss/common/ExcepcionGeneral' xmlns:ns4='http://www.something.com/ws/iss/nameWebConsume' codIdioma='UTF-8' locale='es_MX'>
<Deploy>
***
</Deploy>
<Access>
***
</Access>
<Consumer>
***
</Consumer>
<RequestData>
***
</RequestData>
</ns2:HeaderReq>
</soap:Header>
<soap:Body>
<ns4:CheckSomething xmlns:ns2='http://www.something.com/ws/nss/general/Headers' xmlns:ns3='http://www.something.com/ws/nss/common/ExcepcionGeneral' xmlns:ns4='http://www.something.com/ws/iss/nameWebConsume'>
<Folio>123456789</Folio>
</ns4:CheckSomething>
</soap:Body>
</soap:Envelope>
As you can see there are different tags from both SO, my question is: How I can create the same xml request to consume wsdl service?
My code configuration in classes, every header looks like I post
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "HeaderRequestType", propOrder = {
"deploy",
"access",
"consumer",
"requestData"
})
public class HeaderRequestType {...}
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "CheckSomething", namespace = "http://www.something.com/ws/iss/nameWebConsume", propOrder = {
"folio"
})
public class CheckSomething {...}
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "Deploy", propOrder = {
...
})
public class Deploy {...}
My interface where I consume SOAP
#WebService(targetNamespace = "http://www.something.com/ws/iss/nameWebConsume", name = "nameWebConsume")
#XmlSeeAlso({ObjectFactory.class})
#SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface CheckSomething {
#WebMethod
public void CheckSomething(
#WebParam(partName = "request", name = "CheckSomethingIn", targetNamespace = "http://www.something.com/ws/iss/nameWebConsume") CheckSomethingInType request,
#WebParam(partName = "headerRequest", name = "HeaderReq", targetNamespace = "http://www.something.com/ws/nss/general/Headers", header = true) HeaderRequestType headerRequest,
#WebParam(partName = "response", mode = WebParam.Mode.OUT, name = "CheckSomethingOut", targetNamespace = "http://www.something.com/ws/iss/nameWebConsume") javax.xml.ws.Holder<CheckSomethingOutType> response,
#WebParam(partName = "headerResponse", mode = WebParam.Mode.OUT, name = "HeaderRes", targetNamespace = "http://www.something.com/ws/nss/general/Headers", header = true) javax.xml.ws.Holder<HeaderResponseType> headerResponse
) throws CheckSomethingFault;
}
That's it.
I you need more files where I have configuration I will update my post.
Update 1
I have a response in windows good (with data) and when I try in linux I have an error says: Error in data integration cvc-complex-type 2.4: in element
I currently have a web service with the method:
#Override
#WebResult(Name="OIPResponse")
public Map<String, Object> getOIP(#WebParam(name = "invoice") String invoiceNumber,#WebParam(name = "part") String partNumber)
The normal SOAP request I use to call it looks like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:oip="http://oip.mycompany.com/">
<soapenv:Header/>
<soapenv:Body>
<oip:getOIP>
<invoice>41587182</invoice>
<part>9ZF2A5-570</part>
</oip:getOIP>
</soapenv:Body>
</soapenv:Envelope>
and the response is something like this:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:getOIPResponse xmlns:ns2="http://oip.mycompany.com/">
<OIPResponse>
<entry>
<key>ERR_CODE</key>
</entry>
<entry>
<key>SELLING_OU</key>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">null</value>
</entry>
...
</OIPResponse>
</ns2:getOIPResponse>
</soap:Body>
</soap:Envelope>
I've tested this and it works fine. Now I am wondering if there is a way to include multiple requests in the same SOAP envelope like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:oip="http://oip.mycompany.com/">
<soapenv:Header/>
<soapenv:Body>
<oip:getOIP>
<invoice>41587182</invoice>
<part>9ZF2A5-570</part>
</oip:getOIP>
<oip:getOIP>
<invoice>41587183</invoice>
<part>9ZF2A5-570</part>
</oip:getOIP>
<oip:getOIP>
<invoice>41587184</invoice>
<part>9ZF2A5-570</part>
</oip:getOIP>
<oip:getOIP>
<invoice>41587185</invoice>
<part>9ZF2A5-570</part>
</oip:getOIP>
</soapenv:Body>
</soapenv:Envelope>
and get back something like this:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:getOIPResponse xmlns:ns2="http://oip.mycompany.com/">
<OIPResponse>
...
</OIPResponse>
<OIPResponse>
...
</OIPResponse>
<OIPResponse>
...
</OIPResponse>
...
</ns2:getOIPResponse>
</soap:Body>
</soap:Envelope>
Is there any way to do this?
I ended up creating a POJO called OIPRequest that contained the two parameters I need (invoice and part number) and a new method getOIPMultiple which takes an array of OIPRequests as an input parameter.
import javax.xml.bind.annotation.XmlRootElement;
#XmlRootElement
public class OIPRequest {
public String invoiceNumber, partNumber;
public OIPRequest(String invoice, String part) {
invoiceNumber = invoice;
partNumber = part;
}
public OIPRequest() {
invoiceNumber = "";
partNumber = "";
}
}
This makes the request look like this:
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<getMultipleOIP xmlns="http://oip.mycompany.com/">
<OIPRequest xmlns="">
<invoiceNumber>41587182</invoiceNumber>
<partNumber>9ZF2A5-570</partNumber>
</OIPRequest>
<OIPRequest xmlns="">
<invoiceNumber>41587182</invoiceNumber>
<partNumber>9ZF2A5-570</partNumber>
</OIPRequest>
<OIPRequest xmlns="">
<invoiceNumber>41587182</invoiceNumber>
<partNumber>9ZF2A5-570</partNumber>
</OIPRequest>
</getMultipleOIP>
</Body>
</Envelope>
I have a SOAP request like this, it's working fine:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://com/">
<soapenv:Header/>
<soapenv:Body>
<web:ConversionRate>
<!--Optional:-->
<FromCurrency>?</FromCurrency>
<!--Optional:-->
<ToCurrency>?</ToCurrency>
</web:ConversionRate>
</soapenv:Body>
</soapenv:Envelope>
I was changing the request a litle bit to understand the concepts:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" >
<soapenv:Header/>
<soapenv:Body>
<ConversionRate xmlns="http://com/">>
<!--Optional:-->
<FromCurrency>?</FromCurrency>
<!--Optional:-->
<ToCurrency>?</ToCurrency>
</ConversionRate>
</soapenv:Body>
</soapenv:Envelope>
The second one is not working, throwing a wrong answer.
My service class is
package com;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
#WebService (targetNamespace="http://com/")
public class CurrencyConvertor
{
public String ConversionRate (#WebParam(name = "FromCurrency") String FromCurrency, #WebParam(name = "ToCurrency") String ToCurrency)
{
System.out.println("ST\n" + FromCurrency + "\n" + ToCurrency + "\nEnd" );
switch(FromCurrency+","+ToCurrency)
{
case "USD,INR":
return "58";
case "INR,USD":
return "0.017";
default:
return "XXX";
}
}
}
The second request always falling to default case, the thing is, the values are sending as null since I changed the name space. So my Web service should answer for the second request properly, what should cause the issue, how to rectify this.
your namespace is not correct even it looks well.
I have to change com to com.example, because it is not possible to post answer with link to com only.
tns=http://com.example/ is defined in
the WebService, not for the webmethod. Change your method declaration to
public String ConversionRate (
#WebParam(name = "FromCurrency", tagetNamespace = "http://com.example/") String FromCurrency,
#WebParam(name = "ToCurrency", tagetNamespace = "http://com.example/") String ToCurrency) {
...
}
Even I'm not definitely sure if the XML has valid format
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" >
<soapenv:Header/>
<soapenv:Body>
<ConversionRate xmlns="http://com.example/">
<FromCurrency>?</FromCurrency>
<ToCurrency>?</ToCurrency>
</ConversionRate>
</soapenv:Body>
</soapenv:Envelope>
or namespace is required just for parameters
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" >
<soapenv:Header/>
<soapenv:Body>
<ConversionRate>
<FromCurrency xmlns="http://com.example/">?</FromCurrency>
<ToCurrency xmlns="http://com.example/">?</ToCurrency>
</ConversionRate>
</soapenv:Body>
</soapenv:Envelope>
The request which I want to send is :-
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:idm="http://integration.standardandpoors.com/Schema/IDM">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-23762130">
<wsu:Created>2013-06-09T06:00:44.733Z</wsu:Created>
<wsu:Expires>2013-06-09T08:00:44.733Z</wsu:Expires>
</wsu:Timestamp>
<wsse:BinarySecurityToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" EncodingType="SSHA" ValueType="AccessManagerSSOSecurityToken" wsu:Id="OAMToken">TOKEN HARE</wsse:BinarySecurityToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<idm:findUserById>
<applicationName>APP ID</applicationName>
<userId>USER ID</userId>
</idm:findUserById>
</soapenv:Body>
</soapenv:Envelope>
My current java code is
public class WsClient{
public static void main(String[] args) throws Exception {
IdmService sis = new IdmService();
IdmWebServicePort si = sis.getIdmWebServiceImplPort();
WSBindingProvider bp = (WSBindingProvider)si;
Element node = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream("<wsse:Security xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"> <wsu:Timestamp xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" wsu:Id=\"Timestamp-23762130\"><wsu:Created>2013-06-09T06:00:44.733Z</wsu:Created> <wsu:Expires>2013-06-09T08:00:44.733Z</wsu:Expires></wsu:Timestamp><wsse:BinarySecurityToken xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" EncodingType=\"SSHA\" ValueType=\"AccessManagerSSOSecurityToken\" wsu:Id=\"OAMToken\">token here</wsse:BinarySecurityToken></wsse:Security>".getBytes())).getDocumentElement();
bp.setOutboundHeaders(
Headers.create(node)
);
//si.getSecurityChallengeQuestionsAndAnswersForUser("APP NAME", "USER ID");
User u=si.findUserById("MSA", "test100#sandp.com");
System.out.println(u.getFirstName());
}
}
error which I am getting is :-
Exception in thread "main" java.lang.NoSuchMethodError: com.sun.xml.bind.api.JAXBRIContext.newInstance
I'm having a real hard time with this issue.
Basically I've built a WebService using Java/JAX-WS, this is my Interface
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
#WebService
public interface OperationsInterface {
#WebResult(name = "result")
LoginResponse Login(#WebParam(name = "login") Login login);
#WebResult(name = "result")
String Purchase(#WebParam(name = "purchase") Purchase purchase);
}
Login is just a POJO that contains 2 strings (username and password)
LoginResponse is another POJO, it has this
String status;
int code;
String message;
SubscriptionTier subscriptionTier;
String accountNumber;
String firstName;
String lastName;
Nothing fancy, pretty simple in fact. The request is something like this
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ott="http://ott.amentum.net/">
<soapenv:Header/>
<soapenv:Body>
<ott:Login>
<login>
<username>USERNAME</username>
<password>1234</password>
</login>
</ott:Login>
</soapenv:Body>
</soapenv:Envelope>
And the response comes like this
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:LoginResponse xmlns:ns2="http://ott.amentum.net/">
<result>
<accountNumber>0110000076</accountNumber>
<code>1</code>
<firstName>JOHN</firstName>
<lastName>DOE</lastName>
<message>Login has been successful.</message>
<status>success</status>
<subscriptionTier>
<tier>TVOD</tier>
<tier>CANAL</tier>
<tier>CATCHUP</tier>
</subscriptionTier>
</result>
</ns2:LoginResponse>
</soap:Body>
</soap:Envelope>
As far as I know, this is correct, however, my customer is expecting something like this
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:LoginResponse xmlns:ns2="http://ott.amentum.net/">
<accountNumber>0410089676</accountNumber>
<code>1</code>
<firstName>MARIA DEL CARMEN</firstName>
<lastName>PADILLA MARTIN</lastName>
<message>Login has been successful.</message>
<status>success</status>
<subscriptionTier>
<tier>TVOD</tier>
<tier>CANAL</tier>
<tier>CATCHUP</tier>
</subscriptionTier>
</ns2:LoginResponse>
</soap:Body>
</soap:Envelope>
They want me to remove the result tag, which is the name of the LoginResponse object I created to return the information.
Is there a way to do this?
Thanks in advance