SOAP JAXB namespace prefix marshalling issue



Ok so I have an issue marshaling a soap response.


Here is the soap response



<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://ift.tt/sVJIaE"><env:Header xmlns:env="http://ift.tt/sVJIaE"/>
<env:Body xmlns:env="http://ift.tt/sVJIaE">
<activateServiceResponse xmlns="http://ift.tt/1yQbYOy">
<com:requestToken xmlns:SOAP-ENV="http://ift.tt/sVJIaE" xmlns:com="http://ift.tt/1tFdFZL" xmlns:ns6="http://ift.tt/1yQbZSx" xmlns:phon="http://ift.tt/1yQbZ4U" xmlns:ser="http://ift.tt/1yQbYOy">
<com:clientTransactionId>345678</com:clientTransactionId>
<com:clientId>CCC</com:clientId>
</com:requestToken>
<result xmlns="http://ift.tt/1tFdFZL">
<code>-999</code>
<message>Error: SIM was not Found - Neither Specified. Please specify the SIM Number</message>
</result>
<serverTransactionId xmlns="http://ift.tt/1tFdFZL">c3962e2a-a8d8-43d0-b58f-fdd150d5d8cc</serverTransactionId>
<RuntimeFaultMessage xmlns="http://ift.tt/1yQbZSx"></RuntimeFaultMessage>
</activateServiceResponse>
</env:Body>
</soapenv:Envelope>


here are the pertinent java classes


ObjectFactory.java for commontypes package



//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
// See <a href="http://ift.tt/13Ska0j">http://ift.tt/1qqQ1Dg;
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.12.02 at 12:52:19 PM CST
//


package com.tracfone.commontypes;

import java.math.BigInteger;

import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.namespace.QName;


/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the com.tracfone.commontypes package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory {

private final static QName _SourceSystem_QNAME = new QName("http://ift.tt/1tFdFZL", "sourceSystem");
private final static QName _Language_QNAME = new QName("http://ift.tt/1tFdFZL", "language");
private final static QName _ClientTransactionId_QNAME = new QName("http://ift.tt/1tFdFZL", "clientTransactionId");
private final static QName _BrandName_QNAME = new QName("http://ift.tt/1tFdFZL", "brandName");
private final static QName _ClientId_QNAME = new QName("http://ift.tt/1tFdFZL", "clientId");
private final static QName _ServerTransactionId_QNAME = new QName("http://ift.tt/1tFdFZL", "serverTransactionId");
private final static QName _Message_QNAME = new QName("", "message");
private final static QName _Code_QNAME = new QName("", "code");

/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.tracfone.commontypes
*
*/
public ObjectFactory() {
}

/**
* Create an instance of {@link RequestToken }
*
*/
public RequestToken createRequestToken() {
return new RequestToken();
}

/**
* Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://ift.tt/1tFdFZL", name = "sourceSystem")
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
public JAXBElement<String> createSourceSystem(String value) {
return new JAXBElement<String>(_SourceSystem_QNAME, String.class, null, value);
}

/**
* Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://ift.tt/1tFdFZL", name = "language")
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
public JAXBElement<String> createLanguage(String value) {
return new JAXBElement<String>(_Language_QNAME, String.class, null, value);
}

/**
* Create an instance of {@link JAXBElement }{@code <}{@link BigInteger }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://ift.tt/1tFdFZL", name = "clientTransactionId")
public JAXBElement<BigInteger> createClientTransactionId(BigInteger value) {
return new JAXBElement<BigInteger>(_ClientTransactionId_QNAME, BigInteger.class, null, value);
}

/**
* Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://ift.tt/1tFdFZL", name = "brandName")
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
public JAXBElement<String> createBrandName(String value) {
return new JAXBElement<String>(_BrandName_QNAME, String.class, null, value);
}

/**
* Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://ift.tt/1tFdFZL", name = "clientId")
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
public JAXBElement<String> createClientId(String value) {
return new JAXBElement<String>(_ClientId_QNAME, String.class, null, value);
}

/**
* Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://ift.tt/1tFdFZL", name = "serverTransactionId")
public JAXBElement<String> createServerTransactionId(String value) {
return new JAXBElement<String>(_ServerTransactionId_QNAME, String.class, null, value);
}

/**
* Create an instance of {@link Result }
*
*/
public Result createResult() {
return new Result();
}

/**
* Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}}
*
*/
@XmlElementDecl(namespace = "", name = "message")
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
public JAXBElement<String> createMessage(String value) {
return new JAXBElement<String>(_Message_QNAME, String.class, null, value);
}

/**
* Create an instance of {@link JAXBElement }{@code <}{@link BigInteger }{@code >}}
*
*/
@XmlElementDecl(namespace = "", name = "code")
public JAXBElement<BigInteger> createCode(BigInteger value) {
return new JAXBElement<BigInteger>(_Code_QNAME, BigInteger.class, null, value);
}


}


package-info.java



@javax.xml.bind.annotation.XmlSchema(
xmlns = {
@javax.xml.bind.annotation.XmlNs(namespaceURI = "http://ift.tt/1tFdFZL", prefix = "com"),
},
elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package com.tracfone.commontypes;


Result.java



//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
// See <a href="http://ift.tt/13Ska0j">http://ift.tt/1qqQ1Dg;
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.12.02 at 01:13:45 PM CST
//


package com.tracfone.commontypes;

import java.math.BigInteger;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;


/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://ift.tt/1e4enuw">
* &lt;sequence>
* &lt;element ref="{http://ift.tt/1tFdE7W"/>
* &lt;element ref="{http://ift.tt/1yQbZ4X"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"code",
"message"
})
@XmlRootElement(name = "result")
public class Result {

@XmlElement(required = true, namespace="")
protected BigInteger code;
@XmlElement(required = true, namespace="")
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
@XmlSchemaType(name = "NCName")
protected String message;

/**
* Gets the value of the code property.
*
* @return
* possible object is
* {@link BigInteger }
*
*/
public BigInteger getCode() {
return code;
}

/**
* Sets the value of the code property.
*
* @param value
* allowed object is
* {@link BigInteger }
*
*/
public void setCode(BigInteger value) {
this.code = value;
}

/**
* Gets the value of the message property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getMessage() {
return message;
}

/**
* Sets the value of the message property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setMessage(String value) {
this.message = value;
}

}


Here is the final outputed marshalled response



<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ser:activateServiceResponse xmlns:com="http://ift.tt/1tFdFZL" xmlns:ser="http://ift.tt/1yQbYOy" xmlns:phon="http://ift.tt/1yQbZ4U" xmlns:ns5="http://ift.tt/1yQbZSx">
<com:requestToken>
<com:clientTransactionId>345678</com:clientTransactionId>
<com:clientId>CCC</com:clientId>
</com:requestToken>
<com:result/>
<com:serverTransactionId>c3962e2a-a8d8-43d0-b58f-fdd150d5d8cc</com:serverTransactionId>
<ns5:RuntimeFaultMessage/>
</ser:activateServiceResponse>


The issue is with the Result not marshalling. I think it has to do with the namespace prefix not lining up. Is there anyway to declare a package level namespace prefix, but exclude the application of that prefix from certain classes? Basically don't apply this namespace prefix to x.java class. Or can I override a namespace prefix at the element level? Any help would be greatly appreciated


No comments:

Post a Comment