本文整理汇总了Java中javax.xml.ws.http.HTTPBinding类的典型用法代码示例。如果您正苦于以下问题:Java HTTPBinding类的具体用法?Java HTTPBinding怎么用?Java HTTPBinding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HTTPBinding类属于javax.xml.ws.http包,在下文中一共展示了HTTPBinding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testProviderDispatch
import javax.xml.ws.http.HTTPBinding; //导入依赖的package包/类
@Test
@RunAsClient
public void testProviderDispatch() throws Exception
{
String targetNS = "http://ws.com/";
QName serviceName = new QName(targetNS, "Provider");
QName portName = new QName(targetNS, "ProviderPort");
Service service = Service.create(serviceName);
service.addPort(portName, HTTPBinding.HTTP_BINDING, baseURL.toString());
Dispatch<Source> dispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD);
Source resPayload = dispatch.invoke(new DOMSource(DOMUtils.parse("<ns2:input xmlns:ns2='http://ws.com/'><arg0>hello</arg0></ns2:input>")));
Element docElement = DOMUtils.sourceToElement(resPayload);
Element response = ((Element)DOMUtils.getChildElements(docElement, "return").next());
assertEquals("hello", response.getTextContent());
}
示例2: bindingTypesMatch
import javax.xml.ws.http.HTTPBinding; //导入依赖的package包/类
/**
* Compares the version of the message in the MessageContext to what's expected
* given the ServiceDescription. The behavior is described in the SOAP 1.2
* specification under Appendix 'A'.
*
* @param mc
* @param serviceDesc
* @return
*/
public static boolean bindingTypesMatch(MessageContext mc, EndpointDescription ed) {
Protocol protocol = mc.getMessage().getProtocol();
String bindingType = ed.getBindingType();
if (log.isDebugEnabled()) {
log.debug("Checking for matching binding types.");
log.debug(" message protocol: " + protocol);
log.debug(" binding type: " + bindingType);
}
if (protocol.equals(Protocol.soap11)) {
return (BindingUtils.isSOAP11Binding(bindingType));
} else if (protocol.equals(Protocol.soap12)) {
return (BindingUtils.isSOAP12Binding(bindingType));
} else if (protocol.equals(Protocol.rest)) {
return HTTPBinding.HTTP_BINDING.equalsIgnoreCase(bindingType);
}
return true;
}
示例3: bindingHumanReadableDescription
import javax.xml.ws.http.HTTPBinding; //导入依赖的package包/类
private static String bindingHumanReadableDescription(String ns) {
if (SOAPBinding.SOAP11HTTP_BINDING.equals(ns)) {
return "SOAP 1.1 HTTP Binding";
} else if (SOAPBinding.SOAP11HTTP_MTOM_BINDING.equals(ns)) {
return "SOAP 1.1 MTOM HTTP Binding";
} else if (SOAPBinding.SOAP12HTTP_BINDING.equals(ns)) {
return "SOAP 1.2 HTTP Binding";
} else if (SOAPBinding.SOAP12HTTP_MTOM_BINDING.equals(ns)) {
return "SOAP 1.2 MTOM HTTP Binding";
} else if (MDQConstants.SOAP11JMS_BINDING.equals(ns)) {
return "SOAP 1.1 JMS Binding";
} else if (MDQConstants.SOAP11JMS_MTOM_BINDING.equals(ns)) {
return "SOAP 1.1 MTOM JMS Binding";
} else if (MDQConstants.SOAP12JMS_BINDING.equals(ns)) {
return "SOAP 1.2 JMS Binding";
} else if (MDQConstants.SOAP12JMS_MTOM_BINDING.equals(ns)) {
return "SOAP 1.2 MTOM JMS Binding";
} else if (HTTPBinding.HTTP_BINDING.equals(ns)) {
return "XML HTTP Binding";
} else {
return "Unknown Binding";
}
}
示例4: getWSEndpointReference
import javax.xml.ws.http.HTTPBinding; //导入依赖的package包/类
@Override
public final WSEndpointReference getWSEndpointReference() {
if (binding.getBindingID().equals(HTTPBinding.HTTP_BINDING)) {
throw new java.lang.UnsupportedOperationException(
ClientMessages.UNSUPPORTED_OPERATION("BindingProvider.getEndpointReference(Class<T> class)", "XML/HTTP Binding", "SOAP11 or SOAP12 Binding")
);
}
if (endpointReference != null) {
return endpointReference;
}
String eprAddress = requestContext.getEndpointAddress().toString();
QName portTypeName = null;
String wsdlAddress = null;
List<WSEndpointReference.EPRExtension> wsdlEPRExtensions = new ArrayList<WSEndpointReference.EPRExtension>();
if (wsdlPort != null) {
portTypeName = wsdlPort.getBinding().getPortTypeName();
wsdlAddress = eprAddress + "?wsdl";
//gather EPRExtensions specified in WSDL.
try {
WSEndpointReference wsdlEpr = wsdlPort.getEPR();
if (wsdlEpr != null) {
for (WSEndpointReference.EPRExtension extnEl : wsdlEpr.getEPRExtensions()) {
wsdlEPRExtensions.add(new WSEPRExtension(
XMLStreamBuffer.createNewBufferFromXMLStreamReader(extnEl.readAsXMLStreamReader()), extnEl.getQName()));
}
}
} catch (XMLStreamException ex) {
throw new WebServiceException(ex);
}
}
AddressingVersion av = AddressingVersion.W3C;
this.endpointReference = new WSEndpointReference(
av, eprAddress, getServiceName(), getPortName(), portTypeName, null, wsdlAddress, null, wsdlEPRExtensions, null);
return this.endpointReference;
}
示例5: getEndpointReference
import javax.xml.ws.http.HTTPBinding; //导入依赖的package包/类
@Override
public final W3CEndpointReference getEndpointReference() {
if (binding.getBindingID().equals(HTTPBinding.HTTP_BINDING)) {
throw new java.lang.UnsupportedOperationException(
ClientMessages.UNSUPPORTED_OPERATION("BindingProvider.getEndpointReference()", "XML/HTTP Binding", "SOAP11 or SOAP12 Binding"));
}
return getEndpointReference(W3CEndpointReference.class);
}
示例6: checkValidSOAPMessageDispatch
import javax.xml.ws.http.HTTPBinding; //导入依赖的package包/类
public static void checkValidSOAPMessageDispatch(WSBinding binding, Service.Mode mode) {
// Dispatch<SOAPMessage> is only valid for soap binding and in Service.Mode.MESSAGE
if (DispatchImpl.isXMLHttp(binding))
throw new WebServiceException(DispatchMessages.INVALID_SOAPMESSAGE_DISPATCH_BINDING(HTTPBinding.HTTP_BINDING, SOAPBinding.SOAP11HTTP_BINDING + " or " + SOAPBinding.SOAP12HTTP_BINDING));
if (DispatchImpl.isPAYLOADMode(mode))
throw new WebServiceException(DispatchMessages.INVALID_SOAPMESSAGE_DISPATCH_MSGMODE(mode.name(), Service.Mode.MESSAGE.toString()));
}
示例7: checkValidDataSourceDispatch
import javax.xml.ws.http.HTTPBinding; //导入依赖的package包/类
public static void checkValidDataSourceDispatch(WSBinding binding, Service.Mode mode) {
// Dispatch<DataSource> is only valid with xml/http binding and in Service.Mode.MESSAGE
if (!DispatchImpl.isXMLHttp(binding))
throw new WebServiceException(DispatchMessages.INVALID_DATASOURCE_DISPATCH_BINDING("SOAP/HTTP", HTTPBinding.HTTP_BINDING));
if (DispatchImpl.isPAYLOADMode(mode))
throw new WebServiceException(DispatchMessages.INVALID_DATASOURCE_DISPATCH_MSGMODE(mode.name(), Service.Mode.MESSAGE.toString()));
}
示例8: getBindingIdForToken
import javax.xml.ws.http.HTTPBinding; //导入依赖的package包/类
/**
* JSR-109 defines short-form tokens for standard binding Ids. These are
* used only in DD. So stand alone deployment descirptor should also honor
* these tokens. This method converts the tokens to API's standard
* binding ids
*
* @param lexical binding attribute value from DD. Always not null
* @return returns corresponding API's binding ID or the same lexical
*/
public static @NotNull String getBindingIdForToken(@NotNull String lexical) {
if (lexical.equals("##SOAP11_HTTP")) {
return SOAPBinding.SOAP11HTTP_BINDING;
} else if (lexical.equals("##SOAP11_HTTP_MTOM")) {
return SOAPBinding.SOAP11HTTP_MTOM_BINDING;
} else if (lexical.equals("##SOAP12_HTTP")) {
return SOAPBinding.SOAP12HTTP_BINDING;
} else if (lexical.equals("##SOAP12_HTTP_MTOM")) {
return SOAPBinding.SOAP12HTTP_MTOM_BINDING;
} else if (lexical.equals("##XML_HTTP")) {
return HTTPBinding.HTTP_BINDING;
}
return lexical;
}
示例9: createDispatchSource
import javax.xml.ws.http.HTTPBinding; //导入依赖的package包/类
private Dispatch<Source> createDispatchSource() throws Exception
{
javax.xml.ws.Service service = javax.xml.ws.Service.create(new QName("http://ws.jboss.org", "HelloService"));
service.addPort(new QName("http://ws.jboss.org", "HelloPort"), HTTPBinding.HTTP_BINDING,
"http://ws.jboss.org/endpointAddress");
return service.createDispatch(new QName("http://ws.jboss.org", "HelloPort"), Source.class,
javax.xml.ws.Service.Mode.PAYLOAD);
}
示例10: createDispatch
import javax.xml.ws.http.HTTPBinding; //导入依赖的package包/类
private Dispatch<Object> createDispatch(String target) throws MalformedURLException, JAXBException
{
String targetNS = "http://org.jboss.ws/provider";
QName serviceName = new QName(targetNS, "ProviderService");
QName portName = new QName(targetNS, "ProviderPort");
URL endpointAddress = new URL(baseURL + "/" + target);
Service service = Service.create(serviceName);
service.addPort(portName, HTTPBinding.HTTP_BINDING, endpointAddress.toExternalForm());
JAXBContext jbc = JAXBContext.newInstance(new Class[] { UserType.class });
Dispatch<Object> dispatch = service.createDispatch(portName, jbc, Mode.PAYLOAD);
return dispatch;
}
示例11: createDispatch
import javax.xml.ws.http.HTTPBinding; //导入依赖的package包/类
private Dispatch<Object> createDispatch(String target) throws MalformedURLException, JAXBException
{
String targetNS = "http://org.jboss.ws/httpbinding";
QName serviceName = new QName(targetNS, "ProviderService");
QName portName = new QName(targetNS, "ProviderPort");
URL endpointAddress = new URL(baseURL + "/" + target);
Service service = Service.create(serviceName);
service.addPort(portName, HTTPBinding.HTTP_BINDING, endpointAddress.toExternalForm());
JAXBContext jbc = JAXBContext.newInstance(new Class[] { UserType.class });
Dispatch<Object> dispatch = service.createDispatch(portName, jbc, Mode.PAYLOAD);
return dispatch;
}
示例12: createDispatch
import javax.xml.ws.http.HTTPBinding; //导入依赖的package包/类
private Dispatch<Source> createDispatch(String target) throws MalformedURLException, JAXBException
{
String targetNS = "http://org.jboss.ws/httpbinding";
QName serviceName = new QName(targetNS, "ProviderService");
QName portName = new QName(targetNS, "ProviderPort");
URL endpointAddress = new URL(baseURL + "/" + target);
Service service = Service.create(serviceName);
service.addPort(portName, HTTPBinding.HTTP_BINDING, endpointAddress.toExternalForm());
Dispatch<Source> dispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD);
return dispatch;
}
示例13: isValidInvocationParam
import javax.xml.ws.http.HTTPBinding; //导入依赖的package包/类
private boolean isValidInvocationParam(Object object) {
String bindingId = endpointDesc.getClientBindingID();
// If no bindingId was found, use the default.
if (bindingId == null) {
bindingId = SOAPBinding.SOAP11HTTP_BINDING;
}
// If it's not an HTTP_BINDING, then we can allow for null params,
// but only in PAYLOAD mode per JAX-WS Section 4.3.2.
if (!bindingId.equals(HTTPBinding.HTTP_BINDING)) {
if (mode.equals(Mode.MESSAGE) && object == null) {
throw ExceptionFactory.makeWebServiceException(Messages.getMessage("dispatchNullParamMessageMode"));
}
} else {
// In all cases (PAYLOAD and MESSAGE) we must throw a WebServiceException
// if the parameter is null and request method is POST or PUT.
if (object == null && isPOSTorPUTRequest()) {
throw ExceptionFactory.makeWebServiceException(Messages.getMessage("dispatchNullParamHttpBinding"));
}
}
if (object instanceof DOMSource) {
DOMSource ds = (DOMSource)object;
if (ds.getNode() == null && ds.getSystemId() == null) {
throw ExceptionFactory.makeWebServiceException(Messages.getMessage("dispatchBadDOMSource"));
}
}
// If we've gotten this far, then all is good.
return true;
}
示例14: getDispatch
import javax.xml.ws.http.HTTPBinding; //导入依赖的package包/类
public Dispatch<Object> getDispatch() throws JAXBException {
Service service = Service.create(SERVICE_NAME);
service.addPort(PORT_NAME, HTTPBinding.HTTP_BINDING,ENDPOINT_URL);
JAXBContext jbc = JAXBContext.newInstance("test");
Dispatch<Object> dispatch = service.createDispatch(PORT_NAME, jbc, Service.Mode.PAYLOAD);
return dispatch;
}
示例15: getWSEndpointReference
import javax.xml.ws.http.HTTPBinding; //导入依赖的package包/类
public final WSEndpointReference getWSEndpointReference() {
if (binding.getBindingID().equals(HTTPBinding.HTTP_BINDING))
throw new java.lang.UnsupportedOperationException(ClientMessages.UNSUPPORTED_OPERATION("BindingProvider.getEndpointReference(Class<T> class)", "XML/HTTP Binding", "SOAP11 or SOAP12 Binding"));
if (endpointReference != null) {
return endpointReference;
}
String eprAddress = requestContext.getEndpointAddress().toString();
QName portTypeName = null;
String wsdlAddress = null;
List<WSEndpointReference.EPRExtension> wsdlEPRExtensions = new ArrayList<WSEndpointReference.EPRExtension>();
if(wsdlPort!=null) {
portTypeName = wsdlPort.getBinding().getPortTypeName();
wsdlAddress = eprAddress +"?wsdl";
//gather EPRExtensions specified in WSDL.
try {
WSEndpointReference wsdlEpr = ((WSDLPortImpl) wsdlPort).getEPR();
if (wsdlEpr != null) {
for (WSEndpointReference.EPRExtension extnEl : wsdlEpr.getEPRExtensions()) {
wsdlEPRExtensions.add(new WSEPRExtension(
XMLStreamBuffer.createNewBufferFromXMLStreamReader(extnEl.readAsXMLStreamReader()), extnEl.getQName()));
}
}
} catch (XMLStreamException ex) {
throw new WebServiceException(ex);
}
}
AddressingVersion av = AddressingVersion.W3C;
this.endpointReference = new WSEndpointReference(
av, eprAddress, getServiceName(), getPortName(), portTypeName, null, wsdlAddress, null,wsdlEPRExtensions,null);
return this.endpointReference;
}