Hello all,
I am tyring to call a web service in a post function. I am used SOAPSonar first to test and I can load the wsdl and complete the web service successfully. I copied the xml that SOAPSonar used directly into the code below. I am testing this with Groovy script runner...
import javax.xml.namespace.QName
import javax.xml.ws.Service
import java.net.URL
import groovy.swing.SwingBuilder
import javax.swing.ImageIcon
import org.apache.commons.codec.binary.Base64
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import groovy.xml.DOMBuilder
import groovy.xml.dom.DOMCategory
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
PostMethod post = new PostMethod("http://servernameXX/arsys/WSDL/public/serverXX/HPD_IncidentInterface_Create_WS?wsdl");
def xml = """<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:s0="urn:HPD_IncidentInterface_Create_WS">
<soap:Header>
<s0:AuthenticationInfo>
<s0:userName>mikewhitlock</s0:userName>
<s0:password>Password</s0:password>
</s0:AuthenticationInfo>
</soap:Header>
<soap:Body>
<s0:HelpDesk_Submit_Service>
<s0:First_Name>Michael</s0:First_Name>
<s0:Impact>3-Moderate/Limited</s0:Impact>
<s0:Last_Name>Whitlock</s0:Last_Name>
<s0:Reported_Source>External Escalation</s0:Reported_Source>
<s0:Service_Type>User Service Request</s0:Service_Type>
<s0:Status>New</s0:Status>
<s0:Action>CREATE</s0:Action>
<s0:Create_Request>Yes</s0:Create_Request>
<s0:Summary>Test Web Service 4</s0:Summary>
<s0:Notes>Test Web Service 1 Notes</s0:Notes>
<s0:Urgency>3-Medium</s0:Urgency>
<s0:Work_Info_Summary/>
<s0:Work_Info_Notes/>
<s0:Work_Info_Type>----- Customer Inbound -----</s0:Work_Info_Type>
<s0:Work_Info_Date/>
<s0:Work_Info_Source>Email</s0:Work_Info_Source>
<s0:Work_Info_Locked>Yes</s0:Work_Info_Locked>
<s0:Work_Info_View_Access>Internal</s0:Work_Info_View_Access>
</s0:HelpDesk_Submit_Service>
</soap:Body>
</soap:Envelope>"""
def langs = new XmlParser().parseText(xml);
post.setRequestEntity(new StringRequestEntity(xml, "text/xml", "ISO-8859-1"));
post.setRequestHeader("Content-type", "text/xml; charset=ISO-8859-1");
HttpClient httpclient = new HttpClient();
int result = httpclient.executeMethod(post);
String rep = post.getResponseBodyAsString();
I know it is connecting because if I comment out the last line I get a response of 200. If I include the final line I get this as a response...
<?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions targetNamespace="urn:HPD_IncidentInterface_Create_WS" xmlns:s0="urn:HPD_IncidentInterface_Create_WS" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <wsdl:types> <xsd:schema elementFormDefault="qualified" targetNamespace="urn:HPD_IncidentInterface_Create_WS"> <xsd:element name="HelpDesk_Submit_Service" type="s0:CreateInputMap"/> <xsd:complexType name="CreateInputMap"> <xsd:sequence> <xsd:element name="Assigned_Group" type="xsd:string"/> <xsd:element name="Assigned_Group_Shift_Name" type="xsd:string"/> <xsd:element name="Assigned_Support_Company" type="xsd:string"/> <xsd:element name="Assigned_Support_Organization" type="xsd:string"/> <xsd:element name="Assignee" type="xsd:string"/> <xsd:element name="Categorization_Tier_1" type="xsd:string"/> <xsd:element name="Categorization_Tier_2" type="xsd:string"/> <xsd:element name="Categorization_Tier_3" type="xsd:string"/> <xsd:element name="CI_Name" type="xsd:string"/> <xsd:element name="Closure_Manufacturer" type="xsd:string"/> <xsd:element name="Closure_Product_Category_Tier1" type="xsd:string"/> <xsd:element name="Closure_Product_Category_Tier2" type="xsd:string"/> <xsd:element name="Closure_Product_Category_Tier3" type="xsd:string"/> <xsd:element name="Closure_Product_Model_Version" type="xsd:string"/> <xsd:element name="Closure_Product_Name" type="xsd:string"/> <xsd:element name="Department" type="xsd:string"/> <xsd:element name="First_Name" type="xsd:string"/> <xsd:element name="Impact" type="s0:ImpactType"/> <xsd:element name="Last_Name" type="xsd:string"/> <xsd:element name="Lookup_Keyword" type="xsd:string"/> <xsd:element name="Manufacturer" type="xsd:string"/> <xsd:element name="Product_Categorization_Tier_1" type="xsd:string"/> <xsd:element name="Product_Categorization_Tier_2" type="xsd:string"/> <xsd:element name="Product_Categorization_Tier_3" type="xsd:string"/> <xsd:element name="Product_Model_Version" type="xsd:string"/> <xsd:element name="Product_Name" type="xsd:string"/> <xsd:element name="Reported_Source" type="s0:Reported_SourceType"/> <xsd:element name="Resolution" type="xsd:string"/> <xsd:element name="Resolution_Category_Tier_1" type="xsd:string"/> <xsd:element name="Resolution_Category_Tier_2" type="xsd:string"/> <xsd:element name="Resolution_Category_Tier_3" type="xsd:string"/> <xsd:element name="Service_Type" type="s0:Service_TypeType"/> <xsd:element name="Status" type="s0:StatusType"/> <xsd:element name="Action" type="xsd:string"/> <xsd:element name="Create_Request" type="s0:Create_RequestType"/> <xsd:element name="Summary" type="xsd:string"/> <xsd:element name="Notes" type="xsd:string"/> <xsd:element name="Urgency" type="s0:UrgencyType"/> <xsd:element name="Work_Info_Summary" type="xsd:string"/> <xsd:element name="Work_Info_Notes" type="xsd:string"/> <xsd:element name="Work_Info_Type" type="s0:Work_Info_TypeType"/> <xsd:element name="Work_Info_Date" type="xsd:dateTime"/> <xsd:element name="Work_Info_Source" type="s0:Work_Info_SourceType"/> <xsd:element name="Work_Info_Locked" type="s0:Create_RequestType"/> <xsd:element name="Work_Info_View_Access" type="s0:Work_Info_View_AccessType"/> </xsd:sequence> </xsd:complexType> <xsd:simpleType name="ImpactType"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="1-Extensive/Widespread"/> <xsd:enumeration value="2-Significant/Large"/> <xsd:enumeration value="3-Moderate/Limited"/> <xsd:enumeration value="4-Minor/Localized"/> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="Reported_SourceType"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="Direct Input"/> <xsd:enumeration value="Email"/> <xsd:enumeration value="External Escalation"/> <xsd:enumeration value="Fax"/> <xsd:enumeration value="Systems Management"/> <xsd:enumeration value="Phone"/> <xsd:enumeration value="Voice Mail"/> <xsd:enumeration value="Walk In"/> <xsd:enumeration value="Web"/> <xsd:enumeration value="Other"/> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="Service_TypeType"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="User Service Restoration"/> <xsd:enumeration value="User Service Request"/> <xsd:enumeration value="Infrastructure Restoration"/> <xsd:enumeration value="Infrastructure Event"/> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="StatusType"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="New"/> <xsd:enumeration value="Assigned"/> <xsd:enumeration value="In Progress"/> <xsd:enumeration value="Pending"/> <xsd:enumeration value="Resolved"/> <xsd:enumeration value="Closed"/> <xsd:enumeration value="Cancelled"/> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="Create_RequestType"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="Yes"/> <xsd:enumeration value="No"/> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="UrgencyType"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="1-Critical"/> <xsd:enumeration value="2-High"/> <xsd:enumeration value="3-Medium"/> <xsd:enumeration value="4-Low"/> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="Work_Info_TypeType"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="----- Customer Inbound -----"/> <xsd:enumeration value="Customer Communication"/> <xsd:enumeration value="Customer Follow-up"/> <xsd:enumeration value="Customer Status Update"/> <xsd:enumeration value="----- Customer Outbound -----"/> <xsd:enumeration value="Closure Follow Up"/> <xsd:enumeration value="Detail Clarification"/> <xsd:enumeration value="General Information"/> <xsd:enumeration value="Resolution Communications"/> <xsd:enumeration value="Satisfaction Survey"/> <xsd:enumeration value="Status Update"/> <xsd:enumeration value="----- General -----"/> <xsd:enumeration value="Incident Task / Action"/> <xsd:enumeration value="Problem Script"/> <xsd:enumeration value="Working Log"/> <xsd:enumeration value="Email System"/> <xsd:enumeration value="Paging System"/> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="Work_Info_SourceType"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="Email"/> <xsd:enumeration value="Fax"/> <xsd:enumeration value="Phone"/> <xsd:enumeration value="Voice Mail"/> <xsd:enumeration value="Walk In"/> <xsd:enumeration value="Pager"/> <xsd:enumeration value="System Assignment"/> <xsd:enumeration value="Web"/> <xsd:enumeration value="Other"/> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="Work_Info_View_AccessType"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="Internal"/> <xsd:enumeration value="Public"/> </xsd:restriction> </xsd:simpleType> <xsd:element name="HelpDesk_Submit_ServiceResponse" type="s0:CreateOutputMap"/> <xsd:complexType name="CreateOutputMap"> <xsd:sequence> <xsd:element name="Incident_Number" type="xsd:string"/> </xsd:sequence> </xsd:complexType> <xsd:element name="AuthenticationInfo" type="s0:AuthenticationInfo"/> <xsd:complexType name="AuthenticationInfo"> <xsd:sequence> <xsd:element name="userName" type="xsd:string"/> <xsd:element name="password" type="xsd:string"/> <xsd:element minOccurs="0" name="authentication" type="xsd:string"/> <xsd:element minOccurs="0" name="locale" type="xsd:string"/> <xsd:element minOccurs="0" name="timeZone" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:schema> </wsdl:types> <wsdl:message name="ARAuthenticate"> <wsdl:part element="s0:AuthenticationInfo" name="parameters"/> </wsdl:message> <wsdl:message name="HelpDesk_Submit_ServiceSoapIn"> <wsdl:part element="s0:HelpDesk_Submit_Service" name="parameters"/> </wsdl:message> <wsdl:message name="HelpDesk_Submit_ServiceSoapOut"> <wsdl:part element="s0:HelpDesk_Submit_ServiceResponse" name="parameters"/> </wsdl:message> <wsdl:portType name="HPD_IncidentInterface_Create_WSPortType"> <wsdl:operation name="HelpDesk_Submit_Service"> <wsdl:input message="s0:HelpDesk_Submit_ServiceSoapIn"/> <wsdl:output message="s0:HelpDesk_Submit_ServiceSoapOut"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="HPD_IncidentInterface_Create_WSSoapBinding" type="s0:HPD_IncidentInterface_Create_WSPortType"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="HelpDesk_Submit_Service"> <soap:operation soapAction="urn:HPD_IncidentInterface_Create_WS/HelpDesk_Submit_Service" style="document"/> <wsdl:input> <soap:header message="s0:ARAuthenticate" part="parameters" use="literal"> </soap:header> <soap:body use="literal"/> </wsdl:input> <wsdl:output> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="HPD_IncidentInterface_Create_WSService"> <wsdl:documentation> HelpDesk_Submit_Service Create </wsdl:documentation> <wsdl:port binding="s0:HPD_IncidentInterface_Create_WSSoapBinding" name="HPD_IncidentInterface_Create_WSSoap"> <soap:address location="http://servernameXX/arsys/services/ARService?server=serverXX&webService=HPD_IncidentInterface_Create_WS"/> </wsdl:port> </wsdl:service> </wsdl:defintions>
Any ideas????? I am wondering if the code I have is getting to the SOAP operation 'HelpDesk_Submit_Service'. I am really not too sure though.
Please help.
Thanks,
Mike Whitlock
Once again... once I post I figure it out myself even though I have been working on this throughout the weekend...
post.setRequestHeader("SOAPAction", "urn:HPD_IncidentInterface_Create_WS/HelpDesk_Submit_Service");
IIRC you can just add a new header using httpclient.
Personally I would forget coding it in groovy until you can verify that you can get a sensible response using fiddler. When that's working, you can compare what jira sends by proxying through fiddler.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Update...
I added this line...
post.setURI(new URI("http://servernameXX/arsys/services/ARService?server=XX&webService=HPD_IncidentInterface_Create_WS"));
and now I get the following...
<?xml version="1.0" encoding="ISO-8859-1"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <soapenv:Fault> <faultcode xmlns:ns1="http://xml.apache.org/axis/">ns1:Client.NoSOAPAction</faultcode> <faultstring>no SOAPAction header!</faultstring> <detail> <ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">aix4057.ercot.com</ns2:hostname> </detail> </soapenv:Fault> </soapenv:Body> </soapenv:Envelope>
This is exactly what I was thinking... I am not pointing my xml to the SOAPAction of 'HelpDesk_Submit_Service'
So does anyone know how to do that????
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.