builder.setBaseUri(getBaseURI(tryitWSDL));
} else {
String msg =
WSDL2FormGenerator.class.getName() + " standard WSDL document is not found";
log.error(msg);
throw new CarbonException(msg);
}
axisService = builder.populateService();
updateMockProxyServiceGroup(axisService, MessageContext.getCurrentMessageContext()
.getConfigurationContext().getAxisConfiguration());
List<String> exposeTxList = new ArrayList<String>();
exposeTxList.add(ServerConstants.HTTP_TRANSPORT);
axisService.setExposedTransports(exposeTxList);
ByteArrayOutputStream wsdl2Bos = new ByteArrayOutputStream();
if (hostName == null || hostName.length() == 0) {
hostName = NetworkUtils.getLocalHostname();
}
// Endpoints are changed to those of proxy before printing WSDL to generate tryit.
Map endpointMap = axisService.getEndpoints();
HashMap<String, String> origUrlMap = new HashMap<String, String>();
Set endKeySet = endpointMap.keySet();
// Calculate endpoint for proxy service.
TransportInDescription inDescription =
configCtx.getAxisConfiguration().getTransportIn(ServerConstants.HTTP_TRANSPORT);
Parameter proxyParameter = inDescription.getParameter("proxyPort");
String proxyEndpointPrefix = ServerConstants.HTTP_TRANSPORT + "://" + hostName;
String proxyEndpointPort = ":" + inDescription.getParameter(PORT).getValue();
// We check whether there is a proxyPort specified in the http Endpoint. If there is
// one we need to use that port, but if its 80 we just ignore it.
if (proxyParameter != null && !"-1".equals(proxyParameter.getValue())) {
if (!"80".equals(proxyParameter.getValue())) {
proxyEndpointPort = ":" + proxyParameter.getValue();
} else {
proxyEndpointPort = "";
}
}
String serviceContextRoot = configCtx.getServiceContextPath();
if (!serviceContextRoot.endsWith("/")) {
serviceContextRoot = serviceContextRoot + "/";
}
String proxyEndpoint = proxyEndpointPrefix + proxyEndpointPort + serviceContextRoot +
axisService.getName() + "/";
// Update all endpoints of proxy service.
for (Object anEndKeySet : endKeySet) {
String key = (String) anEndKeySet;
AxisEndpoint ep = (AxisEndpoint) endpointMap.get(key);
origUrlMap.put(key, ep.getEndpointURL());
ep.setEndpointURL(proxyEndpoint);
}
// Original endpoints are restored in order to make call from proxy.
for (Object anEndKeySet : endKeySet) {
String key = (String) anEndKeySet;
AxisEndpoint ep = (AxisEndpoint) endpointMap.get(key);
ep.setEndpointURL(origUrlMap.get(key));
}
axisService.printWSDL2(wsdl2Bos, hostName);
return generateTryitExternal(configCtx, wsdl2Bos, serviceName, operationName,
endpointName, fileResourcesMap, tryitWSDL.substring(0, tryitWSDL.lastIndexOf("/") + 1), fullPage, false);
} catch (IOException e) {
log.error(e.getMessage(), e);
throw new CarbonException(e);
} catch (XMLStreamException e) {
log.error(e.getMessage(), e);
throw new CarbonException(e);
} catch (OMException e) {
log.error(e.getMessage(), e);
throw new CarbonException(e);
} catch (ParserConfigurationException e) {
log.error(e.getMessage(), e);
throw new CarbonException(e);
} catch (TransformerException e) {
log.error(e.getMessage(), e);
throw new CarbonException(e);
} finally {
if (inXMLStream != null) {
try {
inXMLStream.close();
} catch (IOException e) {