Webservices - called using HttpUrlconnection and JAX WS RI - jaxb

In my project, we consume webservices . What was confusing to me was there were some webservices(say A) that were called just using the HttpURLConnection and req/response was marshalled/unmarshalled using JAXB
There is another web service(say B) for which i see many classes with JAX WSRI and its not called using HttpURLConnection. I also see .wsdl files for these webservices.
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.1.1 in JDK 6
* Generated source version: 2.0
*
*/
#WebService(name = "ABPortType", targetNamespace "http://www.ups.com/WSDL/XOLTWS/DCR/v1.0")
#SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface ABCPortType {
#WebMethod(operationName = "ProcessAB", action = = "http://example.com/webservices/xxBinding/v1.0")
#WebResult(name = "xxResponse", targetNamespace = "http://xx.com/XMLSchema/XXWS/AB/v1.0", partName = "Body")
}
MY doubts are
Why are we calling the webservice B with all these extra bloat (end point, JAX WS RI instead of using HttpURLConnection?
can HttpULConnection be used to call this webservice B
For webservice A that is called using HttpURLConnection there is no WSDL (just jaxb classes created from xsd) but whreas the WS that is called using JAXWS RI generated classes has a WSDL. Are the web service A and B implemnted differentely and thats why we call them in different ways
Please help me understand
-Venkat

According to the order of your questions:
If you are using JAX-WS API, may be you want to generate client proxy classes from the WebService, e.g. using the wsimport tool for generate the client stubs from the WSDL document file. So that you work with Java objects and not with XML. Only in special cases, you need a XML handler for advanced features, such as WS-Security.
Yes. You need to work with the XML directly and use JAX-B for marshall/unmarshall the messages.
The WSDL document file describes the SOAP service and the signatures of all the operations available in the service. If A does not have a descriptor (the WSDL document file), may not use the JAX-WS API, e.g. Java WSDP, or the service provider is not exposing the WSDL.

Related

ServiceStack: Generate OpenAPI spec without creating the Service implementation classes

ServiceStack has support for OpenAPI and can generate an OpenAPI spec. However, for APIs/endpoints to be generated in the spec, it is not enough to specify the API details using the Route attributes as described here, you also need to create the Service classes that (eventually) implement the functionality.
Is there a way to make the OpenAPI specification include everything without having to create the Service classes that go with them?
The reason is that sometimes you just want to work on the specification, not implementation (even though you can just skip implementation details and throw a NotImplementedException), and creating those Service classes just to get the spec to show is annoying.
If it doesn't have an implementation it's not a Service and therefore wont have any of ServiceStack's metadata or features available for it.
If you want to skip their implementation you can just create stub implementations for them, e.g:
public class MyServices : Service
{
public object Any(MyRequest1 request) => null;
public object Any(MyRequest2 request) => null;
public object Any(MyRequest3 request) => null;
}

DocuSign - Is there a better way to instantiate the APIclient using the C# sdk in .net core?

I am using E-signature C# SDK to integrate with DocuSign Api's from my .NET6 based API. As per the documentation ApiClient is instantiated like var client = new ApiClient("base address") .
Is there way to use the middleware to create an instance of the ApiClient so that I can only instantiate it once and inject it in my class, to call the SDK methods.
There are multiple constructors you can use.
You can just do new ApiClient() which defaults the basePath to be https://www.docusign.net/restapi
You can also use a Configuration object and pass that to the constructor instead of a basePath.
The most advanced constructor is this:
public ApiClient(string basePath, string oAuthBasePath, WebProxy proxy = null)
This one allows you to specify a different oAuthBasePath and even a WebProxy should you need one.
However, I assume you're actually asking about using dependency injection so that you can have your controllers pass along the singleton.
As it stands right now ApiClient is not implementing any Interface, so you cannot do it directly.
You can create your own class that extends ApiClient, implements some new interface you provide and then you'll be able to get this capability.
You can also take the code for the C# SDK and modify it to be an interface (IApiClient would probably be the name you want to use)

OpenAPI Generator issue with Destination service API specification

I want to get all destinations on subaccount and instance level. In SAP API business Hub, I found the API information and "SAP Cloud SDK" tab to generate code by OpenAPI generator.
https://api.sap.com/api/SAP_CP_CF_Connectivity_Destination/overview
I downloaded the API specification and added dependencies into Cloud SDK for Java project. The code is generated successfully with some errors (unknown models)in generated api classes.
For example in DestinationsOnSubaccountLevelApi.class, model OneOfDestinationNameOnly is imported and used in method but it is not generated in model package.
I looked into API specification and found that there were two types of response entity. That is the reason why the code could not be generated properly. I can modify the API specification to make it work but it should not be the long term solution. Is there any other way to fix this issue?
Unfortunately the SAP Cloud SDK Generator for Open API services is not yet able to understand oneOf relationship that is modeled in the specification.
As an alternative, would you consider using the DestinationAccessor API for resolving single destinations?
You can also directly instantiate an ScpCfDestinationLoader, which allows for querying all destinations:
ScpCfDestinationLoader loader = new ScpCfDestinationLoader();
DestinationOptions options = DestinationOptions
.builder()
.augmentBuilder(ScpCfDestinationOptionsAugmenter.augmenter().retrievalStrategy(ScpCfDestinationRetrievalStrategy.ALWAYS_SUBSCRIBER))
.build();
Try<Iterable<ScpCfDestination>> destinations = loader.tryGetAllDestinations(options);
Similar to the default behavior of DestinationAccessor API, in the code above only the subscriber account will be considered. Other options are:
ScpCfDestinationRetrievalStrategy.ALWAYS_SUBSCRIBER
ScpCfDestinationRetrievalStrategy.ALWAYS_PROVIDER
ScpCfDestinationRetrievalStrategy.SUBSCRIBER_THEN_PROVIDER

Mule Schema validation when wsdl has embedded xsd

In Mule ESB I want to validate incoming SOAP/XML, using a standard Mule "schema-validation filter".
Something like:
<mulexml:schema-validation-filter schemaLocations="xxx.xsd" name="xxxValidationFilter"/>
However this kind of definition seem to assume that the schema is located in a separate xsd-file, whereas in a lot of cases the schema definition is embedded in the "wsdl:types" element of a wsdl-file.
Is there any way to use the Mule schema-validation-filter to validate against schema's which are embedded in the wsdl (except for copying the schema element definitions out of the
wsdl and into a separate xsd-file).
Mule service element tags which expose the service haave an attribute that can enable validation on the incoming request.
validationEnabled="true"
<cxf:simple-service validationEnabled="true"/>
<cxf:jaxws-service validationEnabled="true"/>
<cxf:proxy-service validationEnabled="true"/>
For more information refer to the following Mule documentation link.
http://www.mulesoft.org/documentation/display/current/Building+Web+Services+with+CXF
Hope this helps.

Spring WS and CXF Binding

I want to implement a webservice client using Spring WS JAXB and CXF.
I use CXF to generate my Stubs from a WSDL file.
This WSDL contains the following schema :
For this schema the only thing that cxf generates is an ObjectFactory and no stub.
I want to use Spring Ws marshalSendAndReceive method to send a request to my service but I don't know how to construct my request object from what was generated with CXF.
Someone can help ?
thx
You don't really need CXF to generate the JAXB types from the WSDL file, JDK comes with a tool called xjc which can do this for you - http://docs.oracle.com/javase/6/docs/technotes/tools/share/xjc.html
Can you try using this and see if the artifacts created with this tool suffice.

Resources