I'm quiet new to WCF world.
I've been looking and trying to understand the WSDL file being generated by WCF. the reason I'm looking is that our clients with Java and PHP are having issue importing the WSDL.
Could anyone please kindly help me with following queries:
- <xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="http://localhost:13818/WCFService2/Service.svc?xsd=xsd0" namespace="http://tempuri.org/" />
<xsd:import schemaLocation="http://localhost:13818/WCFService2/Service.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
<xsd:import schemaLocation="http://localhost:13818/WCFService2/Service.svc?xsd=xsd2" namespace="http://schemas.datacontract.org/2004/07/EvalServiceLibrary" />
</xsd:schema>
Query 1
Based on what condition is above import schemalocation tags gets generated? Is it based on number of data contracts and members or somethingelse (what is it?)
- <wsdl:message name="IEvalService_SubmitEval_InputMessage">
<wsdl:part name="parameters" element="tns:SubmitEval" />
</wsdl:message>
- <wsdl:message name="IEvalService_SubmitEval_OutputMessage">
<wsdl:part name="parameters" element="tns:SubmitEvalResponse" />
</wsdl:message>
Query 2:
I don't have any message name IEvalService_SubmitEval_InputMessage. How is above being generated? Also what is part name and element?
<wsdl:portType name="IEvalService">
- <wsdl:operation name="SubmitEval">
<wsdl:input wsaw:Action="http://tempuri.org/IEvalService/SubmitEval" message="tns:IEvalService_SubmitEval_InputMessage" />
<wsdl:output wsaw:Action="http://tempuri.org/IEvalService/SubmitEvalResponse" message="tns:IEvalService_SubmitEval_OutputMessage" />
</wsdl:operation>
</wsdl:portType>
Query 3:
could yo uplease tell me what is "tns:IEvalService_SubmitEval_InputMessage" on above wsdl snippet?
Fianally:
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org
/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org
/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata">
is thre any way to remove the above unnecessary namespace from WCF code? I only know how to change the namespace.
Thank you heaps.
This part depends on number of assemblies involved. The first line represents your service assembly, second line is always included - that some MS predefined elements (but still valid interoperable XSD) and the third line is probably library with your data contracts.
The default pattern is ServiceContractName_OperationContractName_X where X is either InputMessage or OutputMessage to differ between request and response. Part defines content of the message and element is reference to XSD scheme - that element will be defined in first or second schema import from your first question.
tns probably stands for target namespace - it is a prefix of elements defined in your WSDL document. It is just reference to message defined in your second question.
With default stuff no. You would probably need custom encoder.
What errors do your clients have when importing the WSDL? All these parts are valid.
Related
I have inherited a web project that uses WCF in a separate project of my solution to get the data. I'm not familiar with WCF but I was asked to see if I could send another parameter. A developer that is responsible for the actual Web Service will make the adjustment for the extra parameter on his side.
I did a search in the solution for the property called crewMemberConMonthField so I could just copy and paste a new one called crewMemberConMonthField2. I found it in the References.cs and in a FH_FTPService.xsd file.
In the .xsd file I copy and pasted the XML and just changed the name. I then went to the refernces.cs file and added another parameter with the new name (crewMemberConMonthField2). Since I'm using VS 2015 it gives me the option to refactor the name but when I do I get a warning message that basically says "the file could not be refactored. The current object is auto-generated by the Wcf Client Generator and cannot be renamed".
I've been searching for information about this but everything I'm finding is try to walk me through created a WCF. When I look through those examples I'm not seeing anything about a Wcf Client Generator.
I was looking to see if anyone could maybe point me in the right direction.
Here is some of what I have in the reference.cs
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.18408")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://sitename.com/FH_FTPService/")]
public partial class StartRequestType : object, System.ComponentModel.INotifyPropertyChanged {
private StartRequestTypePartition partitionField;
private string crewMemberConMonthField;
private string crewMemberConMonthField2;
private string sequenceConMonth1Field;
private string sequenceConMonth2Field;
and this is in my .xsd file
<schema xmlns:tns="http://sitename.com/FH_FTPService/" elementFormDefault="qualified" targetNamespace="http://sitename.com/FH_FTPService/" xmlns="http://www.w3.org/2001/XMLSchema">
<complexType name="StartRequestType">
<sequence>
<element name="CrewMemberConMonth">
<simpleType>
<restriction base="string">
<length value="7" />
<pattern value="^(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)\d{4}$" />
</restriction>
</simpleType>
</element>
<element name="CrewMemberConMonth2">
<simpleType>
<restriction base="string">
<length value="7" />
<pattern value="^(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)\d{4}$" />
</restriction>
</simpleType>
</element>
I am fighting the last two days with the same problem and I don't know how to fix this. Even not sure if it is an error or not.
I have a CXF Web Service with something I consider very strange and I would like to fix. This is one of the calls that the Web Service deals with:
#WebResult (name="merchantHierarchyParentResponse") MerchantHierarchyParentResponseDTO
getParent(
#WebParam(name="institutionNumber") #XmlElement(required=true) String institutionNumber,
#WebParam(name="clientNumber") String clientNumber,
#WebParam(name="ourReference") String ourReference,
#WebParam(name="accessMerch") String accessMerch,
#WebParam(header=true, name="callerId") String callerId,
#WebParam(header=true, name="timestamp") String timestamp,
#WebParam(header=true, name="signature") String signature
);
As you can see, it receives 4 normal parameters plus 3 extra parameters in the header (callerId, timestamp and signature).
It compiles successfully. Then I deploy it also successfully in a WebLogic server.
Finally, I use SoapUI to test it. I provide SoapUI with the URL that WebLogic is providing me with the WSDL. This is, I am not doing any change in the automatic generated WSDL. This is what I am getting for this getParent in SoupUI:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webService.webservice.omnipay.com.server/">
<soapenv:Header>
<web:signature>?</web:signature>
<web:timestamp>?</web:timestamp>
<web:callerId>?</web:callerId>
</soapenv:Header>
<soapenv:Body>
<web:getParent>
<institutionNumber>?</institutionNumber>
<!--Optional:-->
<clientNumber>?</clientNumber>
<!--Optional:-->
<ourReference>?</ourReference>
<!--Optional:-->
<accessMerch>?</accessMerch>
</web:getParent>
<web:callerId>?</web:callerId>
<web:timestamp>?</web:timestamp>
<web:signature>?</web:signature>
</soapenv:Body>
</soapenv:Envelope>
My question is very clear. I see the 3 parameters in the header section (callerId, timestamp and signature) but why these 3 parameters are AGAIN at the end in the body part. I don't want them in the body part, I want them only in the header.
Any idea why this is happening? Is it a bug?
Hi and thanks to the people that helped me to fix the problem.
Here the portion of the wsdl:binding related with the getParent call:
<wsdl:binding name="ServiceImplServiceSoapBinding" type="tns:IService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getParent">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getParent">
<soap:header encodingStyle="" message="tns:getParent" part="callerId" use="literal"/>
<soap:header encodingStyle="" message="tns:getParent" part="timestamp" use="literal"/>
<soap:header encodingStyle="" message="tns:getParent" part="signature" use="literal"/>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getParentResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
I had to change in the section , this line
<soap:body use="literal"/>
for this one
<soap:body use="literal" parts="parameters"/>
Not very sure why this parts attribute was not generated in my automatically generated WSDL, but well, it fixed my problem. I donĀ“t like to make this manual change in the wsdl. Anyway, at least my problem is fixed.
Take the tripservice wsdl from this link In this wsdl, I replaced the from element with the below(added nillable as true and added min length and max length restriction).
<xs:element minOccurs="0" name="from" nillable="true">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="12"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
Now in my vb.net client i invoked the service by adding service reference, wsdl saved to a local folder.
Dim objproxy As New Tripservice.TripPriceServiceFacadeClient
Dim gh As New Tripservice.trip
gh.adults = 9
gh.duration = 8
gh.rooms = 8
gh.to = "p"
objproxy.getTripPrice(gh)
It will throw end point not found exception, however i am interested in the request xml that is going. I enabled the trace and found that the below request is generated.
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<getTripPrice xmlns="http://trip.price.service">
<trip xmlns="">
<adults>9</adults>
<duration>8</duration>
<from xsi:nil="true"/>
<rooms>8</rooms>
<to>p</to>
</trip>
</getTripPrice>
</s:Body>
</s:Envelope>
The element from xsi:nil="true" is generated, even though i am not touching the element in my vb.net code to generate the request. The element is optional as per the wsdl(min occurs = 0). How can i send a request without the from element name, even passed in the request?
You can't; it is interesting to find out why you changed it to nillable; in doing that, the way .NET code generation works, you leave it no way to know whether it should marshall the tag or not; typically, an optional string that is null is not marshalled. An optional (minOccurs=0) and nillable wouldn't work since there is no "set" indicator (JAXB has it or use to have it) to keep trace whether the user code set the value, null or not null.
When I import a given service using "Add service Reference" on Visual Studio 2008 (SP1) all the Request/Response messages are being unnecessarily wrapped into Message Contracts (named as --> "operationName" + "Request"/"Response" + "1" at the end).
The code generator says:
// CODEGEN: Generating message contract since the operation XXX is neither RPC nor
// document wrapped.
The guys who are generating the wsdl from a Java service say they are specifying DOCUMENT-LITERAL/WRAPPED.
Any help/pointer/clue would be highly appreciated.
Update:
this is a sample of my wsdl for one of the operations that look suspicious. Note the mismatch on the message element attribute for the request, compared to the response.
<!- imports namespaces and defines elements -->
<wsdl:types>
<xsd:schema targetNamespace="http://WHATEVER/" xmlns:xsd_1="http://WHATEVER_1/" xmlns:xsd_2="http://WHATEVER_2/">
<xsd:import namespace="http://WHATEVER_1/" schemaLocation="WHATEVER_1.xsd"/>
<xsd:import namespace="http://WHATEVER_2/" schemaLocation="WHATEVER_2.xsd"/>
<xsd:element name="myOperationResponse" type="xsd_1:MyOperationResponse"/>
<xsd:element name="myOperation" type="xsd_1:MyOperationRequest"/>
</xsd:schema>
</wsdl:types>
<!- declares messages - NOTE the mismatch on the request element attribute compared to response -->
<wsdl:message name="myOperationRequest">
<wsdl:part element="tns:myOperation" name="request"/>
</wsdl:message>
<wsdl:message name="myOperationResponse">
<wsdl:part element="tns:myOperationResponse" name="response"/>
</wsdl:message>
<!- operations -->
<wsdl:portType name="MyService">
<wsdl:operation name="myOperation">
<wsdl:input message="tns:myOperationRequest"/>
<wsdl:output message="tns:myOperationResponse"/>
<wsdl:fault message="tns:myOperationFault" name="myOperationFault"/>
<wsdl:fault message="tns:myOperationFault1" name="myOperationFault1"/>
</wsdl:operation>
</wsdl:portType>
Update 2: I pulled all the types that I had in my imported namespace (they were in a separate xsd) into the wsdl, as I suspected the import could be triggering the message contract generation. To my surprise it was not the case and having all the types defined in the wsdl did not change anything.
I then (out of desperation) started constructing wsdls from scratch and playing with the maxOccurs attributes of element attributes contained in a sequence attribute I was able to reproduce the undesired message contract generation behavior.
Here's a sample of an element:
<xsd:element name="myElement">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="1" name="arg1" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
Playing with maxOccurs on elements that are used as messages (all requests and responses basically) the following happens:
maxOccurs = "1" does not trigger the wrapping
macOcccurs > 1 triggers the wrapping
maxOccurs = "unbounded" triggers the wrapping
I was not able to reproduce this on my production wsdl yet because the nesting of the types goes very deep, and it's gonna take me time to inspect it thoroughly. In the meanwhile I am hoping it might ring a bell - any help highly appreciated.
I had this same issue and this solved it.
I used this:
<wsdl:message name="Method">
<wsdl:part name="parameters" element="s0:Method"/>
</wsdl:message>
<wsdl:message name="MethodResponse">
<wsdl:part name="parameters" element="s0:MethodResponse"/>
</wsdl:message>
Instead of:
<wsdl:message name="Method">
<wsdl:part name="request" element="s0:Method"/>
</wsdl:message>
<wsdl:message name="MethodResponse">
<wsdl:part name="response" element="s0:MethodResponse"/>
</wsdl:message>
I believe someone mentioned it before but I can't upVote their answer yet!
Here is another item to check:
Right click on your service reference in the Solution Explorer and select 'Configure Service Reference'
Check whether or not 'Always generate message contracts' is checked.
Have you tried changing the WSDL so that for every instance of part element="tns:myOperation" name="request", changing the value of the name attribute to 'parameters'.
Did you try using the scvutil
Goto --> Startmenu / Visual Studio 2008 / Tools / VS Command Prompt
Type svcutil, then check out the parameters, especially the /wrapped parameter. Eventually use this to generate your proxy, it gives you alot more control over whats going on
While I know this is a long out dated entry, for those that stumble on this same issue:
Double check that the proxy that was generated doesn't contain any jagged arrays, e.g.
(C#)
private string[][] mystring;
(VB.NET)
Private myString()() As String
I have a VB class in an .asmx file in Visual Studio 2008:
public class foo
public bla as String
end class
It generates the wsdl value:
<s:complexType name="foo">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="bla" type="s:string" />
</s:sequence>
</s:complexType>
But what I want the wsdl to generate is:
<xs:element name="bla" type="xs:string"
sql:datatype="varchar(25)" minOccurs="1" maxOccurs="1">
</xs:element>
Is there a way to do this?
Or can I edit the generated WSDL?
You can use The System.Xml.Serialization.XmlElementAttribute to mark the property IE:
<XmlElement(DataType := "varchar(25)")>
(my vb is a little rusty if this isn't correct
syntax)
You can save off the WSDL and edit it, however, if you change the WSDL, a proxy generated from it may not be able to communicate with your service.
Edit: If you have the target schema, I would suggest that you use xsd.exe or wsdl.exe to generate the classes you need to serialize to valid documents according to that schema.